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.example2;
24
25
26 import jakarta.servlet.http.HttpServletRequest;
27 import org.apache.struts.action.ActionMessage;
28 import org.apache.struts.action.ActionErrors;
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 private static final long serialVersionUID = -5919986074684776364L;
52
53
54
55
56
57
58
59
60 private String action = "Create";
61
62
63
64
65
66 private boolean autoConnect = false;
67
68
69
70
71
72 private String host = null;
73
74
75
76
77
78 private String password = null;
79
80
81
82
83
84 private String type = null;
85
86
87
88
89
90 private String username = null;
91
92
93
94
95
96
97
98
99 public String getAction() {
100
101 return (this.action);
102
103 }
104
105
106
107
108
109
110
111 public void setAction(String action) {
112
113 this.action = action;
114
115 }
116
117
118
119
120
121 public boolean getAutoConnect() {
122
123 return (this.autoConnect);
124
125 }
126
127
128
129
130
131
132
133 public void setAutoConnect(boolean autoConnect) {
134
135 this.autoConnect = autoConnect;
136 }
137
138
139
140
141
142 public String getHost() {
143
144 return (this.host);
145
146 }
147
148
149
150
151
152
153
154 public void setHost(String host) {
155
156 this.host = host;
157
158 }
159
160
161
162
163
164 public String getPassword() {
165
166 return (this.password);
167
168 }
169
170
171
172
173
174
175
176 public void setPassword(String password) {
177
178 this.password = password;
179
180 }
181
182
183
184
185
186 public String getType() {
187
188 return (this.type);
189
190 }
191
192
193
194
195
196
197
198 public void setType(String type) {
199
200 this.type = type;
201
202 }
203
204
205
206
207
208 public String getUsername() {
209
210 return (this.username);
211
212 }
213
214
215
216
217
218
219
220 public void setUsername(String username) {
221
222 this.username = username;
223
224 }
225
226
227
228
229
230
231
232
233
234
235
236 public void reset(ActionMapping mapping, HttpServletRequest request) {
237
238 this.action = "Create";
239 this.autoConnect = false;
240 this.host = null;
241 this.password = null;
242 this.type = null;
243 this.username = null;
244
245 }
246
247
248
249
250
251
252
253
254
255
256
257
258 public ActionErrors validate(ActionMapping mapping,
259 HttpServletRequest request) {
260
261 ActionErrors errors = new ActionErrors();
262
263 if ((host == null) || (host.length() < 1))
264 errors.add("host",
265 new ActionMessage("error.host.required"));
266 if ((username == null) || (username.length() < 1))
267 errors.add("username",
268 new ActionMessage("error.username.required"));
269 if ((password == null) || (password.length() < 1))
270 errors.add("password",
271 new ActionMessage("error.password.required"));
272 if ((type == null) || (type.length() < 1))
273 errors.add("type",
274 new ActionMessage("error.type.required"));
275 else if (!"imap".equals(type) && !"pop3".equals(type))
276 errors.add("type",
277 new ActionMessage("error.type.invalid", type));
278
279 return (errors);
280
281 }
282
283
284 }
285