1 16 17 18 package org.apache.struts.webapp.example2; 19 20 21 import javax.servlet.http.HttpServletRequest ; 22 import org.apache.struts.action.ActionError; 23 import org.apache.struts.action.ActionErrors; 24 import org.apache.struts.action.ActionMapping; 25 import org.apache.struts.validator.ValidatorForm; 26 27 28 50 51 public final class RegistrationForm extends ValidatorForm { 52 53 54 56 57 60 private String action = "Create"; 61 62 63 66 private String fromAddress = null; 67 68 69 72 private String fullName = null; 73 74 75 78 private String password = null; 79 80 81 84 private String password2 = null; 85 86 87 90 private String replyToAddress = null; 91 92 93 94 97 private String username = null; 98 99 100 102 103 106 public String getAction() { 107 108 return (this.action); 109 110 } 111 112 113 118 public void setAction(String action) { 119 120 this.action = action; 121 122 } 123 124 125 128 public String getFromAddress() { 129 130 return (this.fromAddress); 131 132 } 133 134 135 140 public void setFromAddress(String fromAddress) { 141 142 this.fromAddress = fromAddress; 143 144 } 145 146 147 150 public String getFullName() { 151 152 return (this.fullName); 153 154 } 155 156 157 162 public void setFullName(String fullName) { 163 164 this.fullName = fullName; 165 166 } 167 168 169 172 public String getPassword() { 173 174 return (this.password); 175 176 } 177 178 179 184 public void setPassword(String password) { 185 186 this.password = password; 187 188 } 189 190 191 194 public String getPassword2() { 195 196 return (this.password2); 197 198 } 199 200 201 206 public void setPassword2(String password2) { 207 208 this.password2 = password2; 209 210 } 211 212 213 216 public String getReplyToAddress() { 217 218 return (this.replyToAddress); 219 220 } 221 222 223 228 public void setReplyToAddress(String replyToAddress) { 229 230 this.replyToAddress = replyToAddress; 231 232 } 233 234 235 238 public String getUsername() { 239 240 return (this.username); 241 242 } 243 244 245 250 public void setUsername(String username) { 251 252 this.username = username; 253 254 } 255 256 257 259 260 266 public void reset(ActionMapping mapping, HttpServletRequest request) { 267 268 this.action = "Create"; 269 this.fromAddress = null; 270 this.fullName = null; 271 this.password = null; 272 this.password2 = null; 273 this.replyToAddress = null; 274 this.username = null; 275 276 } 277 278 279 289 public ActionErrors validate(ActionMapping mapping, 290 HttpServletRequest request) { 291 292 ActionErrors errors = super.validate(mapping, request); 294 295 if (((password == null) && (password2 != null)) || 297 ((password != null) && (password2 == null)) || 298 ((password != null) && (password2 != null) && 299 !password.equals(password2))) { 300 errors.add("password2", 301 new ActionError("error.password.match")); 302 } 303 return errors; 304 305 } 306 307 308 } 309 | Popular Tags |