Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.forms;
- 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;
- /**
- *
- * @version Version 1.0 2009
- * @author Emmanuel S. Garcia
- */
- public class LoginForm extends ActionForm
- {
- private String userName;
- private String password;
- /**
- * Resets data fields to initial values on login.jsp
- * @param mapping
- * @param request
- */
- public void reset(ActionMapping mapping, HttpServletRequest request)
- {
- password = null;
- userName = null;
- }
- /**
- * Performs validation of data on login.jsp
- * @param mapping
- * @param request
- * @return ActionErrors
- */
- public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
- {
- System.out.println("###LoginForm...");
- ActionErrors errors = new ActionErrors();
- if((userName == null) || (userName.length() < 1))
- errors.add("userName", new ActionError("error.username.required"));
- if((password == null) || (password.length() < 1))
- errors.add("password", new ActionError("error.password.required"));
- return errors;
- }
- /**
- * @return password
- */
- public String getPassword() {
- return password;
- }
- /**
- * @return userName
- */
- public String getUserName() {
- return userName;
- }
- /**
- * @param string
- */
- public void setPassword(String string) {
- password = string;
- }
- /**
- * @param string
- */
- public void setUserName(String string) {
- userName = string;
- }
- }
Add Comment
Please, Sign In to add comment