KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > mailinglistbuilder > struts > MailingListSearchForm


1 package com.dotmarketing.portlets.mailinglistbuilder.struts;
2
3 import java.util.Date JavaDoc;
4 import java.util.GregorianCalendar JavaDoc;
5 import java.util.StringTokenizer JavaDoc;
6
7 import javax.servlet.http.HttpServletRequest JavaDoc;
8
9 import org.apache.struts.action.ActionErrors;
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionMapping;
12 import org.apache.struts.action.ActionMessage;
13 import org.apache.struts.validator.ValidatorForm;
14
15 import com.dotmarketing.util.UtilMethods;
16 import com.liferay.portal.util.Constants;
17
18 public class MailingListSearchForm extends ValidatorForm {
19
20     
21     private String JavaDoc firstName;
22     private String JavaDoc middleName;
23     private String JavaDoc lastName;
24     private String JavaDoc emailAddress;
25     private String JavaDoc dateOfBirthFrom;
26     private String JavaDoc dateOfBirthTo;
27     private Date JavaDoc dateOfBirthFromDate;
28     private Date JavaDoc dateOfBirthToDate;
29     private String JavaDoc company;
30     private String JavaDoc city;
31     private String JavaDoc state;
32     private String JavaDoc country;
33     private String JavaDoc zip;
34     private String JavaDoc phone;
35     private String JavaDoc fax;
36     private String JavaDoc cellPhone;
37     private String JavaDoc lastLoginDateFrom;
38     private String JavaDoc lastLoginDateTo;
39     private Date JavaDoc lastLoginDateFromDate;
40     private Date JavaDoc lastLoginDateToDate;
41     private String JavaDoc mailingListTitle;
42     private boolean allowPublicToSubscribe;
43     private String JavaDoc mailingListInode;
44
45     private String JavaDoc active;
46     private String JavaDoc var1;
47     private String JavaDoc var2;
48     private String JavaDoc var3;
49     private String JavaDoc var4;
50     private String JavaDoc var5;
51     
52     /**
53      * @return Returns the active.
54      */

55     public String JavaDoc getActive() {
56         return active;
57     }
58
59     /**
60      * @param active The active to set.
61      */

62     public void setActive(String JavaDoc active) {
63         this.active = active;
64     }
65
66     /**
67      * @return Returns the var1.
68      */

69     public String JavaDoc getVar1() {
70         return var1;
71     }
72
73     /**
74      * @param var1 The var1 to set.
75      */

76     public void setVar1(String JavaDoc var1) {
77         this.var1 = var1;
78     }
79
80     /**
81      * @return Returns the var2.
82      */

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

90     public void setVar2(String JavaDoc var2) {
91         this.var2 = var2;
92     }
93
94     /**
95      * @return Returns the var3.
96      */

97     public String JavaDoc getVar3() {
98         return var3;
99     }
100
101     /**
102      * @param var3 The var3 to set.
103      */

104     public void setVar3(String JavaDoc var3) {
105         this.var3 = var3;
106     }
107
108     /**
109      * @return Returns the var4.
110      */

111     public String JavaDoc getVar4() {
112         return var4;
113     }
114
115     /**
116      * @param var4 The var4 to set.
117      */

118     public void setVar4(String JavaDoc var4) {
119         this.var4 = var4;
120     }
121
122     /**
123      * @return Returns the var5.
124      */

125     public String JavaDoc getVar5() {
126         return var5;
127     }
128
129     /**
130      * @param var5 The var5 to set.
131      */

132     public void setVar5(String JavaDoc var5) {
133         this.var5 = var5;
134     }
135
136     /**
137      *
138      */

139     public MailingListSearchForm() {
140         super();
141     }
142     
143     /**
144      * @return Returns the cellPhone.
145      */

146     public String JavaDoc getCellPhone() {
147         return cellPhone;
148     }
149     /**
150      * @param cellPhone The cellPhone to set.
151      */

152     public void setCellPhone(String JavaDoc cellPhone) {
153         this.cellPhone = cellPhone;
154     }
155     /**
156      * @return Returns the city.
157      */

158     public String JavaDoc getCity() {
159         return city;
160     }
161     /**
162      * @param city The city to set.
163      */

164     public void setCity(String JavaDoc city) {
165         this.city = city;
166     }
167     /**
168      * @return Returns the company.
169      */

170     public String JavaDoc getCompany() {
171         return company;
172     }
173     /**
174      * @param company The company to set.
175      */

176     public void setCompany(String JavaDoc company) {
177         this.company = company;
178     }
179     /**
180      * @return Returns the country.
181      */

182     public String JavaDoc getCountry() {
183         return country;
184     }
185     /**
186      * @param country The country to set.
187      */

188     public void setCountry(String JavaDoc country) {
189         this.country = country;
190     }
191     /**
192      * @return Returns the dateOfBirthFrom.
193      */

194     public String JavaDoc getDateOfBirthFrom() {
195         return dateOfBirthFrom;
196     }
197     /**
198      * @param dateOfBirthFrom The dateOfBirthFrom to set.
199      */

200     public void setDateOfBirthFrom(String JavaDoc dateOfBirthFrom) {
201         this.dateOfBirthFrom = dateOfBirthFrom;
202         if (dateOfBirthFrom != null && !dateOfBirthFrom.trim().equals("")) {
203             StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc (dateOfBirthFrom, "/");
204             String JavaDoc month = "1";
205             if (tok.hasMoreTokens())
206                 month = tok.nextToken();
207             String JavaDoc day = "1";
208             if (tok.hasMoreTokens())
209                 day = tok.nextToken();
210             String JavaDoc year = "1900";
211             if (tok.hasMoreTokens())
212                 year = tok.nextToken();
213             GregorianCalendar JavaDoc cal = new GregorianCalendar JavaDoc ();
214             cal.set(GregorianCalendar.DATE, Integer.parseInt(day));
215             cal.set(GregorianCalendar.MONTH, Integer.parseInt(month) - 1);
216             cal.set(GregorianCalendar.YEAR, Integer.parseInt(year));
217             cal.set(GregorianCalendar.HOUR_OF_DAY, 0);
218             cal.set(GregorianCalendar.MINUTE, 0);
219             cal.set(GregorianCalendar.SECOND, 0);
220             setDateOfBirthFromDate(cal.getTime());
221         }
222     }
223     /**
224      * @return Returns the dateOfBirthTo.
225      */

226     public String JavaDoc getDateOfBirthTo() {
227         return dateOfBirthTo;
228     }
229     /**
230      * @param dateOfBirthTo The dateOfBirthTo to set.
231      */

232     public void setDateOfBirthTo(String JavaDoc dateOfBirthTo) {
233         this.dateOfBirthTo = dateOfBirthTo;
234         if (dateOfBirthTo != null && !dateOfBirthTo.trim().equals("")) {
235             StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc (dateOfBirthTo, "/");
236             String JavaDoc month = "1";
237             if (tok.hasMoreTokens())
238                 month = tok.nextToken();
239             String JavaDoc day = "1";
240             if (tok.hasMoreTokens())
241                 day = tok.nextToken();
242             String JavaDoc year = "1900";
243             if (tok.hasMoreTokens())
244                 year = tok.nextToken();
245             GregorianCalendar JavaDoc cal = new GregorianCalendar JavaDoc ();
246             cal.set(GregorianCalendar.DATE, Integer.parseInt(day));
247             cal.set(GregorianCalendar.MONTH, Integer.parseInt(month) - 1);
248             cal.set(GregorianCalendar.YEAR, Integer.parseInt(year));
249             cal.set(GregorianCalendar.HOUR_OF_DAY, 23);
250             cal.set(GregorianCalendar.MINUTE, 59);
251             cal.set(GregorianCalendar.SECOND, 59);
252             setDateOfBirthToDate(cal.getTime());
253         }
254     }
255     /**
256      * @return Returns the emailAddress.
257      */

258     public String JavaDoc getEmailAddress() {
259         return emailAddress;
260     }
261     /**
262      * @param emailAddress The emailAddress to set.
263      */

264     public void setEmailAddress(String JavaDoc emailAddress) {
265         this.emailAddress = emailAddress;
266     }
267     /**
268      * @return Returns the fax.
269      */

270     public String JavaDoc getFax() {
271         return fax;
272     }
273     /**
274      * @param fax The fax to set.
275      */

276     public void setFax(String JavaDoc fax) {
277         this.fax = fax;
278     }
279     /**
280      * @return Returns the firstName.
281      */

282     public String JavaDoc getFirstName() {
283         return firstName;
284     }
285     /**
286      * @param firstName The firstName to set.
287      */

288     public void setFirstName(String JavaDoc firstName) {
289         this.firstName = firstName;
290     }
291     /**
292      * @return Returns the lastLoginDateFrom.
293      */

294     public String JavaDoc getLastLoginDateFrom() {
295         return lastLoginDateFrom;
296     }
297     /**
298      * @param lastLoginDateFrom The lastLoginDateFrom to set.
299      */

300     public void setLastLoginDateFrom(String JavaDoc lastLoginDateFrom) {
301         this.lastLoginDateFrom = lastLoginDateFrom;
302         if (lastLoginDateFrom != null && !lastLoginDateFrom.trim().equals("")) {
303             StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc (lastLoginDateFrom, "/");
304             String JavaDoc month = "1";
305             if (tok.hasMoreTokens())
306                 month = tok.nextToken();
307             String JavaDoc day = "1";
308             if (tok.hasMoreTokens())
309                 day = tok.nextToken();
310             String JavaDoc year = "1900";
311             if (tok.hasMoreTokens())
312                 year = tok.nextToken();
313             GregorianCalendar JavaDoc cal = new GregorianCalendar JavaDoc ();
314             cal.set(GregorianCalendar.DATE, Integer.parseInt(day));
315             cal.set(GregorianCalendar.MONTH, Integer.parseInt(month) - 1);
316             cal.set(GregorianCalendar.YEAR, Integer.parseInt(year));
317             cal.set(GregorianCalendar.HOUR_OF_DAY, 0);
318             cal.set(GregorianCalendar.MINUTE, 0);
319             cal.set(GregorianCalendar.SECOND, 0);
320             setLastLoginDateFromDate(cal.getTime());
321         }
322     }
323     /**
324      * @return Returns the lastLoginDateTo.
325      */

326     public String JavaDoc getLastLoginDateTo() {
327         return lastLoginDateTo;
328     }
329     /**
330      * @param lastLoginDateTo The lastLoginDateTo to set.
331      */

332     public void setLastLoginDateTo(String JavaDoc lastLoginDateTo) {
333         this.lastLoginDateTo = lastLoginDateTo;
334         if (lastLoginDateTo != null && !lastLoginDateTo.trim().equals("")) {
335             StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc (lastLoginDateTo, "/");
336             String JavaDoc month = "1";
337             if (tok.hasMoreTokens())
338                 month = tok.nextToken();
339             String JavaDoc day = "1";
340             if (tok.hasMoreTokens())
341                 day = tok.nextToken();
342             String JavaDoc year = "1900";
343             if (tok.hasMoreTokens())
344                 year = tok.nextToken();
345             GregorianCalendar JavaDoc cal = new GregorianCalendar JavaDoc ();
346             cal.set(GregorianCalendar.DATE, Integer.parseInt(day));
347             cal.set(GregorianCalendar.MONTH, Integer.parseInt(month) - 1);
348             cal.set(GregorianCalendar.YEAR, Integer.parseInt(year));
349             cal.set(GregorianCalendar.HOUR_OF_DAY, 23);
350             cal.set(GregorianCalendar.MINUTE, 59);
351             cal.set(GregorianCalendar.SECOND, 59);
352             setLastLoginDateToDate(cal.getTime());
353         }
354     }
355     /**
356      * @return Returns the lastName.
357      */

358     public String JavaDoc getLastName() {
359         return lastName;
360     }
361     /**
362      * @param lastName The lastName to set.
363      */

364     public void setLastName(String JavaDoc lastName) {
365         this.lastName = lastName;
366     }
367     /**
368      * @return Returns the middleName.
369      */

370     public String JavaDoc getMiddleName() {
371         return middleName;
372     }
373     /**
374      * @param middleName The middleName to set.
375      */

376     public void setMiddleName(String JavaDoc middleName) {
377         this.middleName = middleName;
378     }
379     /**
380      * @return Returns the phone.
381      */

382     public String JavaDoc getPhone() {
383         return phone;
384     }
385     /**
386      * @param phone The phone to set.
387      */

388     public void setPhone(String JavaDoc phone) {
389         this.phone = phone;
390     }
391     /**
392      * @return Returns the state.
393      */

394     public String JavaDoc getState() {
395         return state;
396     }
397     /**
398      * @param state The state to set.
399      */

400     public void setState(String JavaDoc state) {
401         this.state = state;
402     }
403     /**
404      * @return Returns the zip.
405      */

406     public String JavaDoc getZip() {
407         return zip;
408     }
409     /**
410      * @param zip The zip to set.
411      */

412     public void setZip(String JavaDoc zip) {
413         this.zip = zip;
414     }
415     /**
416      * @return Returns the dateOfBirthFromDate.
417      */

418     public Date JavaDoc getDateOfBirthFromDate() {
419         return dateOfBirthFromDate;
420     }
421     /**
422      * @param dateOfBirthFromDate The dateOfBirthFromDate to set.
423      */

424     public void setDateOfBirthFromDate(Date JavaDoc dateOfBirthFromDate) {
425         this.dateOfBirthFromDate = dateOfBirthFromDate;
426     }
427     /**
428      * @return Returns the dateOfBirthToDate.
429      */

430     public Date JavaDoc getDateOfBirthToDate() {
431         return dateOfBirthToDate;
432     }
433     /**
434      * @param dateOfBirthToDate The dateOfBirthToDate to set.
435      */

436     public void setDateOfBirthToDate(Date JavaDoc dateOfBirthToDate) {
437         this.dateOfBirthToDate = dateOfBirthToDate;
438     }
439     /**
440      * @return Returns the lastLoginDateFromDate.
441      */

442     public Date JavaDoc getLastLoginDateFromDate() {
443         return lastLoginDateFromDate;
444     }
445     /**
446      * @param lastLoginDateFromDate The lastLoginDateFromDate to set.
447      */

448     public void setLastLoginDateFromDate(Date JavaDoc lastLoginDateFromDate) {
449         this.lastLoginDateFromDate = lastLoginDateFromDate;
450     }
451     /**
452      * @return Returns the lastLoginDateToDate.
453      */

454     public Date JavaDoc getLastLoginDateToDate() {
455         return lastLoginDateToDate;
456     }
457     /**
458      * @param lastLoginDateToDate The lastLoginDateToDate to set.
459      */

460     public void setLastLoginDateToDate(Date JavaDoc lastLoginDateToDate) {
461         this.lastLoginDateToDate = lastLoginDateToDate;
462     }
463     /**
464      * @return Returns the allowPublicToSubscribe.
465      */

466     public boolean isAllowPublicToSubscribe() {
467         return allowPublicToSubscribe;
468     }
469     /**
470      * @param allowPublicToSubscribe The allowPublicToSubscribe to set.
471      */

472     public void setAllowPublicToSubscribe(boolean allowPublicToSubscribe) {
473         this.allowPublicToSubscribe = allowPublicToSubscribe;
474     }
475     /**
476      * @return Returns the mailingListTitle.
477      */

478     public String JavaDoc getMailingListTitle() {
479         return mailingListTitle;
480     }
481     /**
482      * @param mailingListTitle The mailingListTitle to set.
483      */

484     public void setMailingListTitle(String JavaDoc mailingListTitle) {
485         this.mailingListTitle = mailingListTitle;
486     }
487     /**
488      * @return Returns the mailingListInode.
489      */

490     public String JavaDoc getMailingListInode() {
491         return mailingListInode;
492     }
493     /**
494      * @param mailingListInode The mailingListInode to set.
495      */

496     public void setMailingListInode(String JavaDoc mailingListInode) {
497         this.mailingListInode = mailingListInode;
498     }
499     
500 public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
501         
502         ActionErrors errors = new ActionErrors ();
503         boolean withNotFilter = true;
504         if(request.getParameter("cmd")!=null && request.getParameter("cmd").equals(Constants.SEARCH)) {
505             if(UtilMethods.isSet(firstName)){
506                 withNotFilter = false;
507             } else if(UtilMethods.isSet(middleName)){
508                 withNotFilter = false;
509             }else if(UtilMethods.isSet(lastName)){
510                 withNotFilter = false;
511             }else if(UtilMethods.isSet(emailAddress)){
512                 withNotFilter = false;
513             }else if(UtilMethods.isSet(dateOfBirthFrom)){
514                 withNotFilter = false;
515             }else if(UtilMethods.isSet(dateOfBirthTo)){
516                 withNotFilter = false;
517             }else if(UtilMethods.isSet(dateOfBirthFromDate)){
518                 withNotFilter = false;
519             }else if(UtilMethods.isSet(dateOfBirthToDate)){
520                 withNotFilter = false;
521             }else if(UtilMethods.isSet(lastLoginDateFromDate)){
522                 withNotFilter = false;
523             }else if(UtilMethods.isSet(dateOfBirthFromDate)){
524                 withNotFilter = false;
525             }else if(UtilMethods.isSet(lastLoginDateToDate)){
526                 withNotFilter = false;
527             }else if(UtilMethods.isSet(company)){
528                 withNotFilter = false;
529             }else if(UtilMethods.isSet(city)){
530                 withNotFilter = false;
531             }else if(UtilMethods.isSet(state)){
532                 withNotFilter = false;
533             }else if(UtilMethods.isSet(country)){
534                 withNotFilter = false;
535             }else if(UtilMethods.isSet(zip)){
536                 withNotFilter = false;
537             }else if(UtilMethods.isSet(phone)){
538                 withNotFilter = false;
539             }else if(UtilMethods.isSet(fax)){
540                 withNotFilter = false;
541             }else if(UtilMethods.isSet(cellPhone)){
542                 withNotFilter = false;
543             }else if(UtilMethods.isSet(emailAddress)){
544                 withNotFilter = false;
545             }else if(UtilMethods.isSet(var1)){
546                 withNotFilter = false;
547             }else if(UtilMethods.isSet(var2)){
548                 withNotFilter = false;
549             }else if(UtilMethods.isSet(var3)){
550                 withNotFilter = false;
551             }else if(UtilMethods.isSet(var4)){
552                 withNotFilter = false;
553             }else if(UtilMethods.isSet(var5)){
554                 withNotFilter = false;
555             }else if(UtilMethods.isSet(active)) {
556                 withNotFilter = false;
557             }
558             
559             if(withNotFilter){
560                 ActionMessage error = new ActionMessage ("prompt.filterRequired");
561                 errors.add("filter", error);
562                 return errors;
563             }else{
564                 return super.validate(mapping, request);
565             }
566         }
567         return null;
568         
569     }
570 }
571
Popular Tags