Source code: com/clra/web/LogonForm.java
1 /*
2 * Copyright (c) Carnegie Lake Rowing Association 2002. All rights reserved.
3 * Distributed under the GPL license. See doc/COPYING.
4 * $RCSfile: LogonForm.java,v $
5 * $Date: 2003/02/26 03:38:46 $
6 * $Revision: 1.3 $
7 */
8
9 /*
10 * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
11 * reserved.
12 *
13 * The Apache Software License, Version 1.1 (see licenses)
14 */
15 package com.clra.web;
16
17 import javax.servlet.http.HttpServletRequest;
18 import org.apache.log4j.Category;
19 import org.apache.struts.action.ActionError;
20 import org.apache.struts.action.ActionErrors;
21 import org.apache.struts.action.ActionForm;
22 import org.apache.struts.action.ActionMapping;
23
24 /**
25 * Form bean for the user profile page. This form has the following fields,
26 * with default values in square brackets:
27 * <ul>
28 * <li><b>password</b> - Entered password value
29 * <li><b>username</b> - Entered username value
30 * </ul>
31 * From the struts documentation.
32 *
33 * @author Craig R. McClanahan
34 * -- original author
35 * @author <a href="mailto:rphall@pluto.njcc.com">Rick Hall</a>
36 * -- adapted to CLRA
37 * @version $Revision: 1.3 $ $Date: 2003/02/26 03:38:46 $
38 */
39 public final class LogonForm extends ActionForm {
40
41 /** The password */
42 private String password = null;
43
44 /** The username */
45 private String username = null;
46
47 /** Return the password */
48 public String getPassword() {
49 return (this.password);
50 }
51
52 /**
53 * Set the password.
54 *
55 * @param password The new password
56 */
57 public void setPassword(String password) {
58 this.password = password;
59 }
60
61 /** Return the username */
62 public String getUsername() {
63 return (this.username);
64 }
65
66 /**
67 * Set the username.
68 *
69 * @param username The new username
70 */
71 public void setUsername(String username) {
72 this.username = username;
73 }
74
75 /**
76 * Reset all properties to their default values.
77 *
78 * @param mapping The mapping used to select this instance
79 * @param request The servlet request we are processing
80 */
81 public void reset(ActionMapping mapping, HttpServletRequest request) {
82 this.password = null;
83 this.username = null;
84 }
85
86 /**
87 * Validate the properties that have been set from this HTTP request,
88 * and return an <code>ActionErrors</code> object that encapsulates any
89 * validation errors that have been found. If no errors are found, return
90 * <code>null</code> or an <code>ActionErrors</code> object with no
91 * recorded error messages.
92 *
93 * @param mapping The mapping used to select this instance
94 * @param request The servlet request we are processing
95 */
96 public ActionErrors validate(ActionMapping mapping,
97 HttpServletRequest request) {
98
99 System.out.println( "LogonForm.validate..." );
100
101 ActionErrors errors = new ActionErrors();
102 if ((username == null) || (username.length() < 1)) {
103 errors.add("username", new ActionError("error.username.required"));
104 }
105 if ((password == null) || (password.length() < 1)) {
106 errors.add("password", new ActionError("error.password.required"));
107 }
108
109 return errors;
110 } // validate(ActionMapping,HttpServletRequest)
111
112 } // LogonForm
113
114 /*
115 * $Log: LogonForm.java,v $
116 * Revision 1.3 2003/02/26 03:38:46 rphall
117 * Added copyright and GPL license
118 *
119 * Revision 1.2 2002/02/18 18:06:16 rphall
120 * Ran dos2unix to remove ^M (carriage return) from end of lines
121 *
122 * Revision 1.1.1.1 2002/01/03 21:57:28 rphall
123 * Initial load, 5th try, Jan-03-2002 4:57 PM
124 *
125 * Revision 1.1 2001/11/23 19:40:02 rphall
126 * Major revision
127 *
128 */
129