KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > admin > controller > LogonForm


1 package com.quikj.application.communicator.admin.controller;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4 import org.apache.struts.action.ActionError;
5 import org.apache.struts.action.ActionErrors;
6 import org.apache.struts.action.ActionForm;
7 import org.apache.struts.action.ActionMapping;
8
9
10 /**
11  * Form bean for the user profile page. This form has the following fields,
12  * with default values in square brackets:
13  * <ul>
14  * <li><b>password</b> - Entered password value
15  * <li><b>username</b> - Entered username value
16  * </ul>
17  *
18  * @author Vinod Batra
19  * @version $Revision: 1.2 $ $Date: 2003/05/04 19:57:30 $
20  */

21
22 public final class LogonForm extends ActionForm {
23
24
25     // --------------------------------------------------- Instance Variables
26

27
28     /**
29      * The password.
30      */

31     private String JavaDoc password = null;
32
33
34     /**
35      * The username.
36      */

37     private String JavaDoc username = null;
38
39
40     // ----------------------------------------------------------- Properties
41

42
43     /**
44      * Return the password.
45      */

46     public String JavaDoc getPassword() {
47
48     return (this.password);
49
50     }
51
52
53     /**
54      * Set the password.
55      *
56      * @param password The new password
57      */

58     public void setPassword(String JavaDoc password) {
59
60         this.password = password;
61
62     }
63
64
65     /**
66      * Return the username.
67      */

68     public String JavaDoc getUsername() {
69
70     return (this.username);
71
72     }
73
74
75     /**
76      * Set the username.
77      *
78      * @param username The new username
79      */

80     public void setUsername(String JavaDoc username) {
81
82         this.username = username;
83
84     }
85
86
87     // --------------------------------------------------------- Public Methods
88

89
90     /**
91      * Reset all properties to their default values.
92      *
93      * @param mapping The mapping used to select this instance
94      * @param request The servlet request we are processing
95      */

96     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
97
98         this.password = null;
99         this.username = null;
100
101     }
102
103
104     /**
105      * Validate the properties that have been set from this HTTP request,
106      * and return an <code>ActionErrors</code> object that encapsulates any
107      * validation errors that have been found. If no errors are found, return
108      * <code>null</code> or an <code>ActionErrors</code> object with no
109      * recorded error messages.
110      *
111      * @param mapping The mapping used to select this instance
112      * @param request The servlet request we are processing
113      */

114     public ActionErrors validate(ActionMapping mapping,
115                                  HttpServletRequest JavaDoc request) {
116
117         ActionErrors errors = new ActionErrors();
118         if ((username == null) || (username.length() < 1))
119             errors.add("username", new ActionError("error.username.required"));
120         if ((password == null) || (password.length() < 1))
121             errors.add("password", new ActionError("error.password.required"));
122
123         return errors;
124
125     }
126
127
128 }
129
Popular Tags