View Javadoc

1   package org.sourceforge.vlibrary.user.forms;
2   
3   import javax.servlet.http.HttpServletRequest;
4   import org.apache.struts.action.ActionMessage;
5   import org.apache.struts.action.ActionErrors;
6   import org.apache.struts.action.ActionMapping;
7   import org.apache.struts.util.MessageResources;
8   import org.apache.log4j.Logger;
9   
10  
11  /**
12   * Form bean for the ForgotMyPassword page.  This form has the following fields:
13   * <ul>
14   * <li><b>email</b> - The EMAIL address of the reader [REQUIRED]
15   * <li><b>uid</b> - The user id of the reader [REQUIRED]
16   * </ul>
17   *
18   * @version $Revision$ $Date$
19   */
20  
21  public final class ForgotPasswordForm extends LibraryForm {
22      private static final long serialVersionUID = 0;
23      
24      /** log4j Logger */
25      private static Logger logger =
26       Logger.getLogger(ForgotPasswordForm.class.getName());
27      
28      /** Message Resources */
29      private static MessageResources messages =
30       MessageResources.getMessageResources("ApplicationResources");
31      
32      /**
33       * The maintenance action we are performing (Create, Edit or delete).
34       */
35      
36      private String email=null;
37      private String uid=null;
38      
39      public String getClassName() {
40          return ForgotPasswordForm.class.getName();
41      }
42      
43      public String getEmail() {
44          return email;
45      }
46      
47      public void setEmail(String email) {
48          this.email = email;
49      }
50      
51      public String getUid() {
52          return uid;
53      }
54      
55      public void setUid(String uid) {
56          this.uid = uid;
57      }
58      
59      /**
60       * Reset all properties to their default values.
61       *
62       * @param mapping The mapping used to select this instance
63       * @param request The servlet request we are processing
64       */
65      public void reset(ActionMapping mapping, HttpServletRequest request) {
66          this.email = null;
67          this.uid = null;
68      }
69      
70      /**
71       * Validate the properties that have been set from this HTTP request,
72       * and return an <code>ActionErrors</code> object that encapsulates any
73       * validation errors that have been found.  If no errors are found, return
74       * <code>null</code> or an <code>ActionErrors</code> object with no
75       * recorded error messages.
76       *
77       * @param mapping The mapping used to select this instance
78       * @param request The servlet request we are processing
79       */
80      public ActionErrors validate(ActionMapping mapping,
81       HttpServletRequest request) {
82          
83          if (logger.isDebugEnabled()) {
84              logger.debug(messages.getMessage("entering.validate"));
85          }
86          
87          ActionErrors errors = new ActionErrors();
88          
89          if ((email == null) || (email.length() < 1)) {
90              errors.add("email",
91               new ActionMessage("error.reader.email.required"));
92          }
93          
94          if ((uid == null) || (uid.length() < 1)) {
95              errors.add("uid",
96               new ActionMessage("error.reader.uid.required"));
97          }
98          
99          if (logger.isDebugEnabled() && errors.isEmpty()) {
100             logger.debug(messages.getMessage("validate.successful"));
101         }
102         
103         return errors;
104     }
105     
106 }