Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/RuntimeCollective/webapps/form/EmailPasswordForm.java


1   /* $Header: /home/CVS/rjp/src/com/RuntimeCollective/webapps/form/EmailPasswordForm.java,v 1.3 2003/09/30 15:13:13 joe Exp $
2    * $Revision: 1.3 $
3    * $Date: 2003/09/30 15:13:13 $
4    *
5    * ====================================================================
6    *
7    * Josephine : http://www.runtime-collective.com/josephine/index.html
8    *
9    * Copyright (C) 2003 Runtime Collective
10   * 
11   * This product includes software developed by the
12   * Apache Software Foundation (http://www.apache.org/).
13   *
14   * This library is free software; you can redistribute it and/or
15   * modify it under the terms of the GNU Lesser General Public
16   * License as published by the Free Software Foundation; either
17   * version 2.1 of the License, or (at your option) any later version.
18   *
19   * This library is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22   * Lesser General Public License for more details.
23   *
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this library; if not, write to the Free Software
26   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27   *
28   */
29  
30  package com.RuntimeCollective.webapps.form; 
31  
32  import com.RuntimeCollective.webapps.bean.SimpleUser; 
33  import com.RuntimeCollective.webapps.form.BeanForm; 
34  import com.RuntimeCollective.webapps.bean.EntityBean; 
35  import javax.servlet.http.HttpServletRequest; 
36  import java.sql.SQLException;
37  import org.apache.struts.action.ActionError; 
38  import org.apache.struts.action.ActionErrors; 
39  import org.apache.struts.action.ActionForm; 
40  import org.apache.struts.action.ActionMapping; 
41  
42  import com.RuntimeCollective.webapps.RuntimeParameters;
43  
44  /** 
45  * Object that represents basic user details. Can be used for registering a new user, or logging in or editing a new one.
46  * 
47  * @author Joe Faith 
48  */ 
49  public class EmailPasswordForm extends ActionForm { 
50  
51      // == Properties =================================================== 
52  
53      /** The email address of the user. Also used as the unique login identifier. */ 
54      protected String email = ""; 
55      /** Get the email address of the user. Also used as the unique login identifier. */ 
56      public String getEmail() { return this.email; } 
57      /** Set the email address of the user. Also used as the unique login identifier. */ 
58      public void setEmail(String email) { this.email = email; } 
59  
60      /** Validate logon field entries.
61       * <p>Error codes returned:
62       * <li><code>error.logon.null</code> - if either the email or password is "".
63       * <li><code>error.logon.invalidEmail</code> - if the email address is not valid.
64       * <li><code>error.user.confirm</code> - if the confirmation does not match the password.
65       * <li><code>error.logon.passwordShort</code> - if the password was < 6 letters
66       */
67      public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
68    ActionErrors errors = new ActionErrors();
69  
70    RuntimeParameters.log(this, "Email is : " + email);
71    RuntimeParameters.log(this, "Starting validation");
72  
73    if ( email.equals("") || !UserForm.validEmail(email) ) {
74        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.logon.invalidEmail"));
75        RuntimeParameters.log(this, "Email addres is not valid");
76    }
77    RuntimeParameters.log(this, "Ending validation");
78  
79    return errors;
80      }
81  
82  
83  
84      // == BeanForm Methods =================================================== 
85  
86      /** Reset all properties to default values. 
87      * @param mapping The mapping used to select this instance 
88      * @param request The servlet request we are processing 
89      */ 
90      public void reset(ActionMapping mapping, HttpServletRequest request) { 
91          setEmail(""); 
92      } 
93  
94  
95  }