1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.apache.struts.webapp.example;
24
25
26 import javax.servlet.http.HttpServletRequest;
27 import org.apache.struts.action.ActionErrors;
28 import org.apache.struts.action.ActionMessage;
29 import org.apache.struts.action.ActionForm;
30 import org.apache.struts.action.ActionMapping;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 public final class SubscriptionForm extends ActionForm {
51
52
53
54
55
56
57
58
59 private String action = "Create";
60
61
62
63
64
65 private boolean autoConnect = false;
66
67
68
69
70
71 private String host = null;
72
73
74
75
76
77 private String password = null;
78
79
80
81
82
83 private String type = null;
84
85
86
87
88
89 private String username = null;
90
91
92
93
94
95
96
97
98 public String getAction() {
99
100 return (this.action);
101
102 }
103
104
105
106
107
108
109
110 public void setAction(String action) {
111
112 this.action = action;
113
114 }
115
116
117
118
119
120 public boolean getAutoConnect() {
121
122 return (this.autoConnect);
123
124 }
125
126
127
128
129
130
131
132 public void setAutoConnect(boolean autoConnect) {
133
134 this.autoConnect = autoConnect;
135 }
136
137
138
139
140
141 public String getHost() {
142
143 return (this.host);
144
145 }
146
147
148
149
150
151
152
153 public void setHost(String host) {
154
155 this.host = host;
156
157 }
158
159
160
161
162
163 public String getPassword() {
164
165 return (this.password);
166
167 }
168
169
170
171
172
173
174
175 public void setPassword(String password) {
176
177 this.password = password;
178
179 }
180
181
182
183
184
185 public String getType() {
186
187 return (this.type);
188
189 }
190
191
192
193
194
195
196
197 public void setType(String type) {
198
199 this.type = type;
200
201 }
202
203
204
205
206
207 public String getUsername() {
208
209 return (this.username);
210
211 }
212
213
214
215
216
217
218
219 public void setUsername(String username) {
220
221 this.username = username;
222
223 }
224
225
226
227
228
229
230
231
232
233
234
235 public void reset(ActionMapping mapping, HttpServletRequest request) {
236
237 this.action = "Create";
238 this.autoConnect = false;
239 this.host = null;
240 this.password = null;
241 this.type = null;
242 this.username = null;
243
244 }
245
246
247
248
249
250
251
252
253
254
255
256
257 public ActionErrors validate(ActionMapping mapping,
258 HttpServletRequest request) {
259
260 ActionErrors errors = new ActionErrors();
261
262 if ((host == null) || (host.length() < 1))
263 errors.add("host",
264 new ActionMessage("error.host.required"));
265 if ((username == null) || (username.length() < 1))
266 errors.add("username",
267 new ActionMessage("error.username.required"));
268 if ((password == null) || (password.length() < 1))
269 errors.add("password",
270 new ActionMessage("error.password.required"));
271 if ((type == null) || (type.length() < 1))
272 errors.add("type",
273 new ActionMessage("error.type.required"));
274 else if (!"imap".equals(type) && !"pop3".equals(type))
275 errors.add("type",
276 new ActionMessage("error.type.invalid", type));
277
278 return (errors);
279
280 }
281
282
283
284
285
286 public String toString() {
287
288 StringBuffer sb = new StringBuffer(super.toString());
289 sb.append(",action=");
290 sb.append(action);
291 sb.append(",autoConnect=");
292 sb.append(autoConnect);
293 sb.append(",host=");
294 sb.append(host);
295 sb.append(",password=");
296 sb.append(password);
297 sb.append(",type=");
298 sb.append(type);
299 sb.append(",username=");
300 sb.append(username);
301 return (sb.toString());
302
303 }
304
305
306 }
307