⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registerform.java

📁 如题ServletJSP.rar 为网络收集的JSP网站源文件
💻 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;


/**
 * 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() > Account.USER_NAME_MAX_LENGTH ){
            errors.add("userName", new ActionError("error.userName.maxlength") );
		}else if ((password == null) || (password.length() < 1)){
            errors.add("password", new ActionError("error.password.required"));
		}else if( password.length() < Account.PASSWORD_MIN_LENGTH ){
			errors.add("password", new ActionError("error.password.minlength"));
		}else if ( password.length() > Account.PASSWORD_MAX_LENGTH ){
            errors.add("password", new ActionError("error.password.maxlength"));
		}else if( confirmedPassword.length() < Account.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() > Account.PASSWORD_MAX_LENGTH ){
            errors.add("password", new ActionError("error.password.maxlength"));
	 	}else if ( !confirmedPassword.equals( password ) ){
            errors.add("password", new ActionError("error.password.misMatch"));
		}else if ( ( email == null) || ( email.length() < 1)){
            errors.add("email", new ActionError("error.email.required") );
		}else if ( email.length() > Account.EMAIL_MAX_LENGTH ){
            errors.add("email", new ActionError("error.email.maxlength") );
		}
        return errors;

    }


}//EOC

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -