1 package hero.struts.forms; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import org.apache.struts.action.ActionError; 5 import org.apache.struts.action.ActionErrors; 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionMapping; 8 9 10 22 23 public final class UserForm extends ActionForm { 24 25 26 28 29 32 private String name = null; 33 34 35 38 39 private String password = null; 40 41 44 45 private String email = null; 46 47 50 51 private String jabber = null; 52 53 54 56 57 60 public String getName() { 61 62 return (this.name); 63 64 } 65 66 70 public void setName(String name) { 71 72 this.name = name; 73 74 } 75 76 79 public String getPassword() { 80 81 return (this.password); 82 83 } 84 85 89 public void setPassword(String password) { 90 91 this.password = password; 92 93 } 94 95 98 public String getEmail() { 99 100 return (this.email); 101 102 } 103 104 108 public void setEmail(String email) { 109 110 this.email = email; 111 112 } 113 114 117 public String getJabber() { 118 119 return (this.jabber); 120 121 } 122 123 127 public void setJabber(String jabber) { 128 129 this.jabber = jabber; 130 131 } 132 133 134 136 137 143 public void reset(ActionMapping mapping, HttpServletRequest request) { 144 145 this.name = null; 146 this.password = null; 147 this.email = null; 148 this.jabber = null; 149 } 150 151 161 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 162 163 ActionErrors errors = new ActionErrors(); 164 165 if (name == null || name.length()==0) 166 errors.add("name", 167 new ActionError("error.username.required")); 168 if (password == null || password.length()==0) 169 errors.add("password", 170 new ActionError("error.password.required")); 171 if (email == null || email.length()==0) 172 errors.add("email", 173 new ActionError("error.email.required")); 174 if (jabber == null || jabber.length()==0) 175 errors.add("jabber", 176 new ActionError("error.jabber.required")); 177 178 return (errors); 179 180 } 181 } 182
| Popular Tags
|