1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package examples.simple;
20
21 import javax.servlet.http.HttpServletRequest;
22
23 import org.apache.struts.action.ActionErrors;
24 import org.apache.struts.action.ActionForm;
25 import org.apache.struts.action.ActionMapping;
26 import org.apache.struts.action.ActionMessage;
27
28 /***
29 * A simple ActionForm
30 *
31 * @version $Rev: 421486 $ $Date: 2006-07-12 20:37:08 -0700 (Wed, 12 Jul 2006) $
32 */
33 public class SimpleActionForm extends ActionForm {
34
35
36
37 /*** Name */
38 private String name = null;
39
40 /*** Secret */
41 private String secret = null;
42
43 /*** Color */
44 private String color = null;
45
46 /*** Confirm */
47 private boolean confirm = false;
48
49 /*** Rating */
50 private String rating = null;
51
52 /*** Message */
53 private String message = null;
54
55 /*** Hidden */
56 private String hidden = null;
57
58
59
60 /***
61 * Constructor for MultiboxActionForm.
62 */
63 public SimpleActionForm() {
64 super();
65 }
66
67
68
69 /***
70 * Reset all properties to their default values.
71 *
72 * @param mapping The mapping used to select this instance
73 * @param request The servlet request we are processing
74 */
75 public void reset(ActionMapping mapping, HttpServletRequest request) {
76
77 this.name = null;
78 this.secret = null;
79 this.color = null;
80 this.confirm = false;
81 this.rating = null;
82 this.message = null;
83 this.hidden = null;
84
85 }
86
87 /***
88 * Validate the properties that have been set from this HTTP request,
89 * and return an <code>ActionMessages</code> object that encapsulates any
90 * validation errors that have been found. If no errors are found, return
91 * <code>null</code> or an <code>ActionMessages</code> object with no
92 * recorded error messages.
93 *
94 * @param mapping The mapping used to select this instance
95 * @param request The servlet request we are processing
96 *
97 * @return ActionMessages if any validation errors occurred
98 */
99 public ActionErrors validate(
100 ActionMapping mapping,
101 HttpServletRequest request) {
102
103 ActionErrors errors = new ActionErrors();
104
105
106 if ((name == null) || (name.length() < 1)) {
107 errors.add("name", new ActionMessage("errors.name.required"));
108 }
109
110
111 if ((secret == null) || (secret.length() < 1)) {
112 errors.add("secret", new ActionMessage("errors.secret.required"));
113 }
114
115 return (errors);
116
117 }
118
119
120
121 /***
122 * Returns the color.
123 * @return String
124 */
125 public String getColor() {
126 return color;
127 }
128
129 /***
130 * Returns the confirm.
131 * @return boolean
132 */
133 public boolean getConfirm() {
134 return confirm;
135 }
136
137 /***
138 * Returns the hidden.
139 * @return String
140 */
141 public String getHidden() {
142 return hidden;
143 }
144
145 /***
146 * Returns the message.
147 * @return String
148 */
149 public String getMessage() {
150 return message;
151 }
152
153 /***
154 * Returns the name.
155 * @return String
156 */
157 public String getName() {
158 return name;
159 }
160
161 /***
162 * Returns the rating.
163 * @return String
164 */
165 public String getRating() {
166 return rating;
167 }
168
169 /***
170 * Returns the secret.
171 * @return String
172 */
173 public String getSecret() {
174 return secret;
175 }
176
177 /***
178 * Sets the color.
179 * @param color The color to set
180 */
181 public void setColor(String color) {
182 this.color = color;
183 }
184
185 /***
186 * Sets the confirm.
187 * @param confirm The confirm to set
188 */
189 public void setConfirm(boolean confirm) {
190 this.confirm = confirm;
191 }
192
193 /***
194 * Sets the hidden.
195 * @param hidden The hidden to set
196 */
197 public void setHidden(String hidden) {
198 this.hidden = hidden;
199 }
200
201 /***
202 * Sets the message.
203 * @param message The message to set
204 */
205 public void setMessage(String message) {
206 this.message = message;
207 }
208
209 /***
210 * Sets the name.
211 * @param name The name to set
212 */
213 public void setName(String name) {
214 this.name = name;
215 }
216
217 /***
218 * Sets the rating.
219 * @param rating The rating to set
220 */
221 public void setRating(String rating) {
222 this.rating = rating;
223 }
224
225 /***
226 * Sets the secret.
227 * @param secret The secret to set
228 */
229 public void setSecret(String secret) {
230 this.secret = secret;
231 }
232
233 }