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.ActionForm; 27 import org.apache.struts.action.ActionMapping; 28 import org.apache.struts.action.ActionMessage; 29 30 31 46 47 public final class SubscriptionForm extends ActionForm { 48 49 50 52 53 56 private String action = "Create"; 57 58 59 62 private boolean autoConnect = false; 63 64 65 68 private String host = null; 69 70 71 74 private String password = null; 75 76 77 80 private String type = null; 81 82 83 86 private String username = null; 87 88 89 91 92 95 public String getAction() { 96 97 return (this.action); 98 99 } 100 101 102 107 public void setAction(String action) { 108 109 this.action = action; 110 111 } 112 113 114 117 public boolean getAutoConnect() { 118 119 return (this.autoConnect); 120 121 } 122 123 124 129 public void setAutoConnect(boolean autoConnect) { 130 131 this.autoConnect = autoConnect; 132 } 133 134 135 138 public String getHost() { 139 140 return (this.host); 141 142 } 143 144 145 150 public void setHost(String host) { 151 152 this.host = host; 153 154 } 155 156 157 160 public String getPassword() { 161 162 return (this.password); 163 164 } 165 166 167 172 public void setPassword(String password) { 173 174 this.password = password; 175 176 } 177 178 179 182 public String getType() { 183 184 return (this.type); 185 186 } 187 188 189 194 public void setType(String type) { 195 196 this.type = type; 197 198 } 199 200 201 204 public String getUsername() { 205 206 return (this.username); 207 208 } 209 210 211 216 public void setUsername(String username) { 217 218 this.username = username; 219 220 } 221 222 223 225 226 232 public void reset(ActionMapping mapping, HttpServletRequest request) { 233 234 this.action = "Create"; 235 this.autoConnect = false; 236 this.host = null; 237 this.password = null; 238 this.type = null; 239 this.username = null; 240 241 } 242 243 244 254 public ActionErrors validate(ActionMapping mapping, 255 HttpServletRequest request) { 256 257 ActionErrors errors = new ActionErrors(); 258 259 if ((host == null) || (host.length() < 1)) 260 errors.add("host", 261 new ActionMessage("error.host.required")); 262 if ((username == null) || (username.length() < 1)) 263 errors.add("username", 264 new ActionMessage("error.username.required")); 265 if ((password == null) || (password.length() < 1)) 266 errors.add("password", 267 new ActionMessage("error.password.required")); 268 if ((type == null) || (type.length() < 1)) 269 errors.add("type", 270 new ActionMessage("error.type.required")); 271 else if (!"imap".equals(type) && !"pop3".equals(type)) 272 errors.add("type", 273 new ActionMessage("error.type.invalid", type)); 274 275 return (errors); 276 277 } 278 279 280 } 281 282 | Popular Tags |