1 18 19 20 package org.apache.struts.webapp.example; 21 22 23 import javax.servlet.http.HttpServletRequest ; 24 25 import org.apache.struts.action.ActionErrors; 26 import org.apache.struts.action.ActionMapping; 27 import org.apache.struts.action.ActionMessage; 28 import org.apache.struts.validator.ValidatorForm; 29 30 31 52 53 public final class RegistrationForm extends ValidatorForm { 54 55 56 58 59 62 private String action = "Create"; 63 64 65 68 private String fromAddress = null; 69 70 71 74 private String fullName = null; 75 76 77 80 private String password = null; 81 82 83 86 private String password2 = null; 87 88 89 92 private String replyToAddress = null; 93 94 95 96 99 private String username = null; 100 101 102 104 105 108 public String getAction() { 109 110 return (this.action); 111 112 } 113 114 115 120 public void setAction(String action) { 121 122 this.action = action; 123 124 } 125 126 127 130 public String getFromAddress() { 131 132 return (this.fromAddress); 133 134 } 135 136 137 142 public void setFromAddress(String fromAddress) { 143 144 this.fromAddress = fromAddress; 145 146 } 147 148 149 152 public String getFullName() { 153 154 return (this.fullName); 155 156 } 157 158 159 164 public void setFullName(String fullName) { 165 166 this.fullName = fullName; 167 168 } 169 170 171 174 public String getPassword() { 175 176 return (this.password); 177 178 } 179 180 181 186 public void setPassword(String password) { 187 188 this.password = password; 189 190 } 191 192 193 196 public String getPassword2() { 197 198 return (this.password2); 199 200 } 201 202 203 208 public void setPassword2(String password2) { 209 210 this.password2 = password2; 211 212 } 213 214 215 218 public String getReplyToAddress() { 219 220 return (this.replyToAddress); 221 222 } 223 224 225 230 public void setReplyToAddress(String replyToAddress) { 231 232 this.replyToAddress = replyToAddress; 233 234 } 235 236 237 240 public String getUsername() { 241 242 return (this.username); 243 244 } 245 246 247 252 public void setUsername(String username) { 253 254 this.username = username; 255 256 } 257 258 259 261 262 268 public void reset(ActionMapping mapping, HttpServletRequest request) { 269 270 this.action = "Create"; 271 this.fromAddress = null; 272 this.fullName = null; 273 this.password = null; 274 this.password2 = null; 275 this.replyToAddress = null; 276 this.username = null; 277 278 } 279 280 281 291 public ActionErrors validate(ActionMapping mapping, 292 HttpServletRequest request) { 293 294 ActionErrors errors = super.validate(mapping, request); 296 297 if (!password.equals(password2)) { 299 errors.add("password2", 300 new ActionMessage("error.password.match")); 301 } 302 return errors; 303 304 } 305 306 307 } 308 | Popular Tags |