1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package examples.simple;
23
24 import jakarta.servlet.http.HttpServletRequest;
25
26 import org.apache.struts.action.ActionErrors;
27 import org.apache.struts.action.ActionForm;
28 import org.apache.struts.action.ActionMapping;
29 import org.apache.struts.action.ActionMessage;
30
31
32
33
34
35
36 public class SimpleActionForm extends ActionForm {
37 private static final long serialVersionUID = 4189849944389346127L;
38
39
40
41
42 private String name = null;
43
44
45 private String secret = null;
46
47
48 private String color = null;
49
50
51 private boolean confirm = false;
52
53
54 private String rating = null;
55
56
57 private String message = null;
58
59
60 private String hidden = null;
61
62
63
64
65
66
67 public SimpleActionForm() {
68 super();
69 }
70
71
72
73
74
75
76
77
78
79 public void reset(ActionMapping mapping, HttpServletRequest request) {
80
81 this.name = null;
82 this.secret = null;
83 this.color = null;
84 this.confirm = false;
85 this.rating = null;
86 this.message = null;
87 this.hidden = null;
88
89 }
90
91
92
93
94
95
96
97
98
99
100
101
102
103 public ActionErrors validate(
104 ActionMapping mapping,
105 HttpServletRequest request) {
106
107 ActionErrors errors = new ActionErrors();
108
109
110 if ((name == null) || (name.length() < 1)) {
111 errors.add("name", new ActionMessage("errors.name.required"));
112 }
113
114
115 if ((secret == null) || (secret.length() < 1)) {
116 errors.add("secret", new ActionMessage("errors.secret.required"));
117 }
118
119 return (errors);
120
121 }
122
123
124
125
126
127
128
129 public String getColor() {
130 return color;
131 }
132
133
134
135
136
137 public boolean getConfirm() {
138 return confirm;
139 }
140
141
142
143
144
145 public String getHidden() {
146 return hidden;
147 }
148
149
150
151
152
153 public String getMessage() {
154 return message;
155 }
156
157
158
159
160
161 public String getName() {
162 return name;
163 }
164
165
166
167
168
169 public String getRating() {
170 return rating;
171 }
172
173
174
175
176
177 public String getSecret() {
178 return secret;
179 }
180
181
182
183
184
185 public void setColor(String color) {
186 this.color = color;
187 }
188
189
190
191
192
193 public void setConfirm(boolean confirm) {
194 this.confirm = confirm;
195 }
196
197
198
199
200
201 public void setHidden(String hidden) {
202 this.hidden = hidden;
203 }
204
205
206
207
208
209 public void setMessage(String message) {
210 this.message = message;
211 }
212
213
214
215
216
217 public void setName(String name) {
218 this.name = name;
219 }
220
221
222
223
224
225 public void setRating(String rating) {
226 this.rating = rating;
227 }
228
229
230
231
232
233 public void setSecret(String secret) {
234 this.secret = secret;
235 }
236
237 }