KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > events > struts > EventRegistrationForm


1 package com.dotmarketing.portlets.events.struts;
2
3 import java.util.Date JavaDoc;
4 import java.util.StringTokenizer JavaDoc;
5
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7
8 import org.apache.commons.lang.builder.EqualsBuilder;
9 import org.apache.commons.lang.builder.HashCodeBuilder;
10 import org.apache.commons.lang.builder.ToStringBuilder;
11 import org.apache.struts.action.ActionError;
12 import org.apache.struts.action.ActionErrors;
13 import org.apache.struts.action.ActionMapping;
14 import org.apache.struts.validator.ValidatorForm;
15
16
17 /** @author David Torres */
18 public class EventRegistrationForm extends ValidatorForm {
19
20     private long inode;
21     private long eventInode;
22     private Date JavaDoc registrationDate;
23     private String JavaDoc parent1Name;
24     private String JavaDoc parent2Name;
25     private String JavaDoc student1Name;
26     private String JavaDoc student1Grade;
27     private String JavaDoc student2Name;
28     private String JavaDoc student2Grade;
29     private String JavaDoc student3Name;
30     private String JavaDoc student3Grade;
31     private String JavaDoc student4Name;
32     private String JavaDoc student4Grade;
33     private String JavaDoc student5Name;
34     private String JavaDoc student5Grade;
35     private int numberAttending;
36     private String JavaDoc comments;
37     private String JavaDoc email;
38     private int registationRandomId;
39
40     public EventRegistrationForm() {
41         this.comments = "";
42         this.email = "";
43         this.eventInode = 0;
44         this.inode = 0;
45         this.numberAttending = 1;
46         this.parent1Name = "";
47         this.parent2Name = "";
48         this.registrationDate = new Date JavaDoc();
49         this.student1Name = "";
50         this.student1Grade = "";
51         this.student2Name = "";
52         this.student2Grade = "";
53         this.student3Name = "";
54         this.student3Grade = "";
55         this.student4Name = "";
56         this.student4Grade = "";
57         this.student5Name = "";
58         this.student5Grade = "";
59     }
60
61     public void setInode(long inode) {
62         this.inode = inode;
63     }
64
65     public long getInode() {
66         return this.inode;
67     }
68
69     /**
70      * @return Returns the eventInode.
71      */

72     public long getEventInode() {
73         return eventInode;
74     }
75     /**
76      * @param eventInode The eventInode to set.
77      */

78     public void setEventInode(long eventInode) {
79         this.eventInode = eventInode;
80     }
81     /**
82      * @return Returns the comments.
83      */

84     public String JavaDoc getComments() {
85         return comments;
86     }
87     /**
88      * @param comments The comments to set.
89      */

90     public void setComments(String JavaDoc comments) {
91         this.comments = comments;
92     }
93     /**
94      * @return Returns the email.
95      */

96     public String JavaDoc getEmail() {
97         return email;
98     }
99     /**
100      * @param email The email to set.
101      */

102     public void setEmail(String JavaDoc email) {
103         this.email = email;
104     }
105     /**
106      * @return Returns the numberAttending.
107      */

108     public int getNumberAttending() {
109         return numberAttending;
110     }
111     /**
112      * @param numberAttending The numberAttending to set.
113      */

114     public void setNumberAttending(int numberAttending) {
115         this.numberAttending = numberAttending;
116     }
117     /**
118      * @return Returns the parent1Name.
119      */

120     public String JavaDoc getParent1Name() {
121         return parent1Name;
122     }
123     /**
124      * @param parent1Name The parent1Name to set.
125      */

126     public void setParent1Name(String JavaDoc parent1Name) {
127         this.parent1Name = parent1Name;
128     }
129     /**
130      * @return Returns the parent2Name.
131      */

132     public String JavaDoc getParent2Name() {
133         return parent2Name;
134     }
135     /**
136      * @param parent2Name The parent2Name to set.
137      */

138     public void setParent2Name(String JavaDoc parent2Name) {
139         this.parent2Name = parent2Name;
140     }
141     /**
142      * @return Returns the registrationDate.
143      */

144     public Date JavaDoc getRegistrationDate() {
145         return registrationDate;
146     }
147     /**
148      * @param registrationDate The registrationDate to set.
149      */

150     public void setRegistrationDate(Date JavaDoc registrationDate) {
151         this.registrationDate = registrationDate;
152     }
153     /**
154      * @return Returns the student1Grade.
155      */

156     public String JavaDoc getStudent1Grade() {
157         return student1Grade;
158     }
159     /**
160      * @param student1Grade The student1Grade to set.
161      */

162     public void setStudent1Grade(String JavaDoc student1Grade) {
163         this.student1Grade = student1Grade;
164     }
165     /**
166      * @return Returns the student1Name.
167      */

168     public String JavaDoc getStudent1Name() {
169         return student1Name;
170     }
171     /**
172      * @param student1Name The student1Name to set.
173      */

174     public void setStudent1Name(String JavaDoc student1Name) {
175         this.student1Name = student1Name;
176     }
177     /**
178      * @return Returns the student2Grade.
179      */

180     public String JavaDoc getStudent2Grade() {
181         return student2Grade;
182     }
183     /**
184      * @param student2Grade The student2Grade to set.
185      */

186     public void setStudent2Grade(String JavaDoc student2Grade) {
187         this.student2Grade = student2Grade;
188     }
189     /**
190      * @return Returns the student2Name.
191      */

192     public String JavaDoc getStudent2Name() {
193         return student2Name;
194     }
195     /**
196      * @param student2Name The student2Name to set.
197      */

198     public void setStudent2Name(String JavaDoc student2Name) {
199         this.student2Name = student2Name;
200     }
201     /**
202      * @return Returns the student3Grade.
203      */

204     public String JavaDoc getStudent3Grade() {
205         return student3Grade;
206     }
207     /**
208      * @param student3Grade The student3Grade to set.
209      */

210     public void setStudent3Grade(String JavaDoc student3Grade) {
211         this.student3Grade = student3Grade;
212     }
213     /**
214      * @return Returns the student3Name.
215      */

216     public String JavaDoc getStudent3Name() {
217         return student3Name;
218     }
219     /**
220      * @param student3Name The student3Name to set.
221      */

222     public void setStudent3Name(String JavaDoc student3Name) {
223         this.student3Name = student3Name;
224     }
225     /**
226      * @return Returns the student4Grade.
227      */

228     public String JavaDoc getStudent4Grade() {
229         return student4Grade;
230     }
231     /**
232      * @param student4Grade The student4Grade to set.
233      */

234     public void setStudent4Grade(String JavaDoc student4Grade) {
235         this.student4Grade = student4Grade;
236     }
237     /**
238      * @return Returns the student4Name.
239      */

240     public String JavaDoc getStudent4Name() {
241         return student4Name;
242     }
243     /**
244      * @param student4Name The student4Name to set.
245      */

246     public void setStudent4Name(String JavaDoc student4Name) {
247         this.student4Name = student4Name;
248     }
249     /**
250      * @return Returns the student5Grade.
251      */

252     public String JavaDoc getStudent5Grade() {
253         return student5Grade;
254     }
255     /**
256      * @param student5Grade The student5Grade to set.
257      */

258     public void setStudent5Grade(String JavaDoc student5Grade) {
259         this.student5Grade = student5Grade;
260     }
261     /**
262      * @return Returns the student5Name.
263      */

264     public String JavaDoc getStudent5Name() {
265         return student5Name;
266     }
267     /**
268      * @param student5Name The student5Name to set.
269      */

270     public void setStudent5Name(String JavaDoc student5Name) {
271         this.student5Name = student5Name;
272     }
273     public boolean equals(Object JavaDoc other) {
274         if (!(other instanceof EventRegistrationForm)) {
275             return false;
276         }
277
278         EventRegistrationForm castOther = (EventRegistrationForm) other;
279
280         EqualsBuilder eb = new EqualsBuilder ();
281         eb.append(this.getInode(), castOther.getInode());
282         
283         return eb.isEquals();
284     }
285
286     public int hashCode() {
287         return new HashCodeBuilder().append(getInode()).toHashCode();
288     }
289
290     public void reset() {
291         this.comments = "";
292         this.email = "";
293         this.eventInode = 0;
294         this.inode = 0;
295         this.numberAttending = 1;
296         this.parent1Name = "";
297         this.parent2Name = "";
298         this.registrationDate = new Date JavaDoc();
299         this.student1Name = "";
300         this.student1Grade = "";
301         this.student2Name = "";
302         this.student2Grade = "";
303         this.student3Name = "";
304         this.student3Grade = "";
305         this.student4Name = "";
306         this.student4Grade = "";
307         this.student5Name = "";
308         this.student5Grade = "";
309     }
310
311     public String JavaDoc toString() {
312         return new ToStringBuilder(this).append("inode", getInode()).toString();
313     }
314
315     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
316         ActionErrors errors = new ActionErrors ();
317         
318         if (this.parent1Name.equals("")) {
319             ActionError error = new ActionError ("prompt.parent1_name");
320             errors.add("parent1Name", error);
321         }
322         /*if (this.student1Name.equals("")) {
323             ActionError error = new ActionError ("prompt.student1_name");
324             errors.add("student1Name", error);
325         }
326         if (this.student1Grade.equals("")) {
327             ActionError error = new ActionError ("prompt.student1_grade");
328             errors.add("student1Grade", error);
329         }
330         if (this.numberAttending == 0) {
331             ActionError error = new ActionError ("prompt.number_attending");
332             errors.add("numberAttending", error);
333         }*/

334         if (this.email.equals("")) {
335             ActionError error = new ActionError ("prompt.email_address");
336             errors.add("email", error);
337         } else {
338             StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc (email, "@");
339             if (tok.countTokens() != 2) {
340                 ActionError error = new ActionError ("prompt.email_address_format");
341                 errors.add("email", error);
342             }
343         }
344         return errors;
345     }
346     
347     /**
348      * @return Returns the registationRandomId.
349      */

350     public int getRegistationRandomId() {
351         return registationRandomId;
352     }
353     /**
354      * @param registationRandomId The registationRandomId to set.
355      */

356     public void setRegistationRandomId(int registationRandomId) {
357         this.registationRandomId = registationRandomId;
358     }
359 }
360
Popular Tags