1
2
3
4
5
6
7 package net.stff.ical.gui.struts.formbeans;
8
9 import java.util.Iterator;
10 import java.util.Vector;
11
12 import javax.servlet.http.HttpServletRequest;
13
14 import net.stff.ical.beans.CalendarData;
15 import net.stff.ical.beans.ICal;
16 import net.stff.ical.beans.IEvent;
17 import net.stff.ical.validators.DateValidator;
18
19 import org.apache.struts.action.ActionError;
20 import org.apache.struts.action.ActionErrors;
21 import org.apache.struts.action.ActionForm;
22 import org.apache.struts.action.ActionMapping;
23
24 /***
25 * @author buntekuh
26 *
27 * To change the template for this generated type comment go to
28 * Window - Preferences - Java - Code Generation - Code and Comments
29 */
30 public class EventFormBean extends ActionForm{
31
32 private String method;
33
34 private IEvent iEvent;
35 private String cal;
36
37 private final static int ALLFLAGS= DateValidator.DAYFLAG | DateValidator.HOURSFLAG | DateValidator.MINUTESFLAG | DateValidator.MONTHFLAG | DateValidator.YEARFLAG;
38
39 public EventFormBean(IEvent event, ICal cal){
40 super();
41 iEvent= event;
42 this.cal= cal.getName();
43 }
44 public EventFormBean(CommFormBean vb, CalendarData data){
45 super();
46 iEvent= new IEvent(vb.getBean(), data);
47 this.cal= vb.getBean().getCalendar();
48 }
49
50
51
52 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
53
54 Vector errors= new Vector();
55 ActionErrors errs= new ActionErrors();
56
57 if (request.getParameter("IEvent.allday") == null){
58 iEvent.setAllday(false);
59 if (iEvent.getDtstart() == null){
60 errors.add("EventFormBean.mustHaveStarttime");
61 }
62 if (iEvent.getDtend() == null){
63 errors.add("EventFormBean.mustHaveEndtime");
64 }
65 }
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 String s= iEvent.getSummary();
99 if ((s == null) || (s.equals(""))){
100 errors.add("EventFormBean.mustHaveTitle");
101 }
102 if (errors.size() == 0){
103 return errs;
104 }
105 Iterator i= errors.iterator();
106 while (i.hasNext()){
107 String err= (String)i.next();
108 errs.add(err, new ActionError(err));
109 }
110 return errs;
111 }
112
113 /***
114 * @return Returns the iCal.
115 */
116 public String getCalName() {
117 return cal;
118 }
119 /***
120 * @param cal The iCal to set.
121 */
122 public void setCalName(String cal) {
123 this.cal = cal;
124 }
125 /***
126 * @return Returns the method.
127 */
128 public String getMethod() {
129 return method;
130 }
131
132 /***
133 * @param method The method to set.
134 */
135 public void setMethod(String method) {
136 this.method = method;
137 }
138 /***
139 * @return Returns the iEvent.
140 */
141 public IEvent getIEvent() {
142 return iEvent;
143 }
144 /***
145 * @param iEvent The iEvent to set.
146 */
147 public void setIEvent(IEvent iEvent) {
148 this.iEvent = iEvent;
149 }
150 }