1:
 2:/**
 3: * Title:        <p>
 4: * Description:  <p>
 5: * Copyright:    Copyright (c) <p>
 6: * Company:      <p>
 7: * @author
 8: * @version 1.0
 9: */
10:
11:import atg.droplet.*;
12:import atg.servlet.*;
13:import javax.servlet.*;
14:import java.io.*;
15:
16:public class MyFormHandler extends GenericFormHandler {
17:
18:    private static final String ERRMSG_BAD_SALARY = "Salary must be greater than $10,000";
19:    private static final String ERRMSG_BAD_FNAME = "First Name must have a value";
20:    /**
21:     * properties
22:     */
23:    private String mFirstName;
24:    private String mLastName;
25:    private float mSalary;
26:
27:    /**
28:     * setters and getters
29:     */
30:    public void setFirstName( String pFirstName ){
31:        mFirstName = pFirstName;
32:    }
33:
34:    public void setLastName( String pLastName ){
35:        mLastName = pLastName;
36:    }
37:
38:    public void setSalary( float pSalary ){
39:        mSalary = pSalary;
40:    }
41:
42:    public String getFirstName(){
43:        return mFirstName;
44:    }
45:
46:    public String getLastName(){
47:        return mLastName;
48:    }
49:
50:    public float getSalary(){
51:        return mSalary;
52:    }
53:
54:    /**
55:     * The default constructor
56:     */
57:
58:    public MyFormHandler() {
59:    }
60:
61:    public boolean handleSubmit(DynamoHttpServletRequest pRequest,
62:                  DynamoHttpServletResponse pResponse)
63:      throws ServletException, IOException {
64:        //validate salary
65:        if (mSalary <10000){
66:            //capture the error
67:            this.addFormException( new DropletException( this.ERRMSG_BAD_SALARY ));
68:        }
69:
70:        if ((mFirstName == null)||(mFirstName.trim().equals(""))){
71:            this.addFormException( new DropletException( this.ERRMSG_BAD_FNAME ));
72:        }
73:
74:        //Normally: if there are errors then redirect and return true
75:        return true;
76:    }
77:
78:}
1