📄 registerform.java
字号:
package org.redsoft.forum.web;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.redsoft.forum.dao.PersistentAccount;/** * Form bean for the user register screen. * <ul> * <li><b>author</b>-Entered user name( login id ) * <li><b>password</b> - Entered password * <li><b>confirmed password</b> - Entered confirmed password * <li><b>email</b> - Entered the email * </ul> * * @author Charles Huang * @version 1.0 March 25,2002 */public final class RegisterForm extends ActionForm { /** * The user name(login id) */ private String userName = null; /** * password */ private String password = null; /** * Re-entered password */ private String confirmedPassword = null; /** * email */ private String email = null; /** * Return the user name( login id ) */ public String getUserName() { return (this.userName); } /** * Set the user name * * @param String - The user name */ public void setUserName( final String userName ) { this.userName = userName; } /** * Return the password */ public String getPassword() { return (this.password); } /** * Set the password * * @param String - The password */ public void setPassword( final String password ) { this.password = password; } /** * Return the confirmedPassword */ public String getConfirmedPassword() { return (this.confirmedPassword); } /** * Set the confirmed password * * @param String - The confirmed password */ public void setConfirmedPassword( final String confirmedPassword ) { this.confirmedPassword = confirmedPassword; } /** * Return the email */ public String getEmail() { return (this.email); } /** * Set the email * * @param String - The email */ public void setEmail( final String email) { this.email = email; } /** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { this.password = null; this.confirmedPassword = null; } /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if ((userName == null) || (userName.length() < 1)){ errors.add("userName", new ActionError("error.userName.required") ); }else if ( userName.length() > PersistentAccount.USER_NAME_MAX_LENGTH ){ errors.add("userName", new ActionError("error.userName.maxlength") ); } if ((password == null) || (password.length() < 1)){ errors.add("password", new ActionError("error.password.required")); }else if( password.length() < PersistentAccount.PASSWORD_MIN_LENGTH ){ errors.add("password", new ActionError("error.password.minlength")); }else if ( password.length() > PersistentAccount.PASSWORD_MAX_LENGTH ){ errors.add("password", new ActionError("error.password.maxlength")); }else if( confirmedPassword.length() < PersistentAccount.PASSWORD_MIN_LENGTH ){ errors.add("password", new ActionError("error.password.minlength")); } else if ( ( confirmedPassword == null) || ( confirmedPassword.length() < 1)){ errors.add("password", new ActionError("error.confirmedPassword.required")); }else if ( confirmedPassword.length() > PersistentAccount.PASSWORD_MAX_LENGTH ){ errors.add("password", new ActionError("error.password.maxlength")); }else if ( !confirmedPassword.equals( password ) ){ errors.add("password", new ActionError("error.password.misMatch")); } if ( ( email == null) || ( email.length() < 1)){ errors.add("email", new ActionError("error.email.required") ); }else if ( email.length() > PersistentAccount.EMAIL_MAX_LENGTH ){ errors.add("email", new ActionError("error.email.maxlength") ); } return errors; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -