1 4 package hero.struts.forms; 5 6 7 import javax.servlet.http.HttpServletRequest ; 8 import org.apache.struts.action.ActionError; 9 import org.apache.struts.action.ActionErrors; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionMapping; 12 13 14 25 26 27 public final class LoginForm extends ActionForm { 28 private String userName = null; 29 private String password = null; 30 31 35 public String getUserName() { 36 return (userName); 37 } 38 39 43 public void setUserName(String newUserName) { 44 userName = newUserName; 45 } 46 47 51 public String getPassword() { 52 return (password); 53 } 54 55 59 public void setPassword(String newPassword) { 60 password = newPassword; 61 } 62 63 64 70 public void reset(ActionMapping mapping, HttpServletRequest request) { 71 userName = null; 72 password = null; 73 74 } 75 76 86 public ActionErrors validate(ActionMapping mapping, 87 HttpServletRequest request) { 88 ActionErrors errors = new ActionErrors(); 89 if( userName == null || userName.length()==0 ){ 90 errors.add("userName",new ActionError("error.userName.required")); 91 } 92 93 if( password == null || password.length()==0 ){ 94 errors.add("password",new ActionError("error.password.required")); 95 } 96 return (errors); 97 } 98 99 100 101 } 102 103
| Popular Tags
|