1 package com.dotmarketing.portlets.events.struts; 2 3 import java.util.Date ; 4 import java.util.StringTokenizer ; 5 6 import javax.servlet.http.HttpServletRequest ; 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 18 public class EventRegistrationForm extends ValidatorForm { 19 20 private long inode; 21 private long eventInode; 22 private Date registrationDate; 23 private String parent1Name; 24 private String parent2Name; 25 private String student1Name; 26 private String student1Grade; 27 private String student2Name; 28 private String student2Grade; 29 private String student3Name; 30 private String student3Grade; 31 private String student4Name; 32 private String student4Grade; 33 private String student5Name; 34 private String student5Grade; 35 private int numberAttending; 36 private String comments; 37 private String 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 (); 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 72 public long getEventInode() { 73 return eventInode; 74 } 75 78 public void setEventInode(long eventInode) { 79 this.eventInode = eventInode; 80 } 81 84 public String getComments() { 85 return comments; 86 } 87 90 public void setComments(String comments) { 91 this.comments = comments; 92 } 93 96 public String getEmail() { 97 return email; 98 } 99 102 public void setEmail(String email) { 103 this.email = email; 104 } 105 108 public int getNumberAttending() { 109 return numberAttending; 110 } 111 114 public void setNumberAttending(int numberAttending) { 115 this.numberAttending = numberAttending; 116 } 117 120 public String getParent1Name() { 121 return parent1Name; 122 } 123 126 public void setParent1Name(String parent1Name) { 127 this.parent1Name = parent1Name; 128 } 129 132 public String getParent2Name() { 133 return parent2Name; 134 } 135 138 public void setParent2Name(String parent2Name) { 139 this.parent2Name = parent2Name; 140 } 141 144 public Date getRegistrationDate() { 145 return registrationDate; 146 } 147 150 public void setRegistrationDate(Date registrationDate) { 151 this.registrationDate = registrationDate; 152 } 153 156 public String getStudent1Grade() { 157 return student1Grade; 158 } 159 162 public void setStudent1Grade(String student1Grade) { 163 this.student1Grade = student1Grade; 164 } 165 168 public String getStudent1Name() { 169 return student1Name; 170 } 171 174 public void setStudent1Name(String student1Name) { 175 this.student1Name = student1Name; 176 } 177 180 public String getStudent2Grade() { 181 return student2Grade; 182 } 183 186 public void setStudent2Grade(String student2Grade) { 187 this.student2Grade = student2Grade; 188 } 189 192 public String getStudent2Name() { 193 return student2Name; 194 } 195 198 public void setStudent2Name(String student2Name) { 199 this.student2Name = student2Name; 200 } 201 204 public String getStudent3Grade() { 205 return student3Grade; 206 } 207 210 public void setStudent3Grade(String student3Grade) { 211 this.student3Grade = student3Grade; 212 } 213 216 public String getStudent3Name() { 217 return student3Name; 218 } 219 222 public void setStudent3Name(String student3Name) { 223 this.student3Name = student3Name; 224 } 225 228 public String getStudent4Grade() { 229 return student4Grade; 230 } 231 234 public void setStudent4Grade(String student4Grade) { 235 this.student4Grade = student4Grade; 236 } 237 240 public String getStudent4Name() { 241 return student4Name; 242 } 243 246 public void setStudent4Name(String student4Name) { 247 this.student4Name = student4Name; 248 } 249 252 public String getStudent5Grade() { 253 return student5Grade; 254 } 255 258 public void setStudent5Grade(String student5Grade) { 259 this.student5Grade = student5Grade; 260 } 261 264 public String getStudent5Name() { 265 return student5Name; 266 } 267 270 public void setStudent5Name(String student5Name) { 271 this.student5Name = student5Name; 272 } 273 public boolean equals(Object 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 (); 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 toString() { 312 return new ToStringBuilder(this).append("inode", getInode()).toString(); 313 } 314 315 public ActionErrors validate(ActionMapping mapping, HttpServletRequest 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 334 if (this.email.equals("")) { 335 ActionError error = new ActionError ("prompt.email_address"); 336 errors.add("email", error); 337 } else { 338 StringTokenizer tok = new StringTokenizer (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 350 public int getRegistationRandomId() { 351 return registationRandomId; 352 } 353 356 public void setRegistationRandomId(int registationRandomId) { 357 this.registationRandomId = registationRandomId; 358 } 359 } 360 | Popular Tags |