1 16 17 package examples.app3; 18 19 20 import javax.servlet.http.HttpServletRequest ; 21 import org.apache.struts.action.ActionError; 22 import org.apache.struts.action.ActionErrors; 23 import org.apache.struts.action.ActionForm; 24 import org.apache.struts.action.ActionMapping; 25 26 27 39 40 public final class LogonForm extends ActionForm 41 { 42 43 44 45 46 48 49 52 private String password = null; 53 54 55 58 private String username = null; 59 60 61 63 66 public String getPassword() 67 { 68 69 return (this.password); 70 71 } 72 73 74 79 public void setPassword(String password) 80 { 81 82 this.password = password; 83 84 } 85 86 87 90 public String getUsername() 91 { 92 93 return (this.username); 94 95 } 96 97 98 103 public void setUsername(String username) 104 { 105 106 this.username = username; 107 108 } 109 110 111 113 114 120 public void reset(ActionMapping mapping, 121 HttpServletRequest request) 122 { 123 124 setPassword(null); 125 setUsername(null); 126 127 } 128 129 130 136 public ActionErrors validate(ActionMapping mapping, 137 HttpServletRequest request) 138 { 139 140 ActionErrors errors = new ActionErrors(); 141 142 if ((username == null) || (username.length() < 1)) 143 errors.add("username", new ActionError("error.username.required")); 144 145 if ((password == null) || (password.length() < 1)) 146 errors.add("password", new ActionError("error.password.required")); 147 148 return errors; 149 150 } 151 152 } | Popular Tags |