KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > backoffice > form > LoginForm


1 package org.nextime.ion.backoffice.form;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4
5 import org.apache.struts.action.ActionError;
6 import org.apache.struts.action.ActionErrors;
7 import org.apache.struts.action.ActionForm;
8 import org.apache.struts.action.ActionMapping;
9
10 public class LoginForm extends ActionForm {
11     
12     private String JavaDoc login;
13     private String JavaDoc password;
14
15     /**
16      * Returns the login.
17      * @return String
18      */

19     public String JavaDoc getLogin() {
20         return login;
21     }
22
23
24     /**
25      * Returns the password.
26      * @return String
27      */

28     public String JavaDoc getPassword() {
29         return password;
30     }
31
32
33     /**
34      * Sets the login.
35      * @param login The login to set
36      */

37     public void setLogin(String JavaDoc login) {
38         this.login = (login==null)?null:login.trim();
39     }
40
41
42     /**
43      * Sets the password.
44      * @param password The password to set
45      */

46     public void setPassword(String JavaDoc password) {
47         this.password = password;
48     }
49
50     
51
52     /**
53      * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
54      */

55     public ActionErrors validate(ActionMapping arg0, HttpServletRequest JavaDoc request) {
56         ActionErrors errors = new ActionErrors();
57         if( "".equals(getLogin()) ) {
58             ActionError error = new ActionError("error.login.loginMissing");
59             errors.add("login",error);
60         }
61         if( "".equals(getPassword()) ) {
62             ActionError error = new ActionError("error.login.passwordMissing");
63             errors.add("password",error);
64         }
65         return errors;
66     }
67
68
69     /**
70      * @see org.apache.struts.action.ActionForm#reset(ActionMapping, HttpServletRequest)
71      */

72     public void reset(ActionMapping arg0, HttpServletRequest JavaDoc arg1) {
73         setLogin(null);
74         setPassword(null);
75     }
76
77
78 }
79
80
Popular Tags