KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > applications > webtalk > controller > TrafficReportForm


1 /*
2  * TrafficReportForm.java
3  *
4  * Created on March 14, 2003, 9:39 PM
5  */

6
7 package com.quikj.application.communicator.applications.webtalk.controller;
8
9 import javax.servlet.http.HttpServletRequest JavaDoc;
10 import org.apache.struts.util.*;
11 import org.apache.struts.action.ActionError;
12 import org.apache.struts.action.ActionErrors;
13 import org.apache.struts.action.ActionForm;
14 import org.apache.struts.action.ActionMapping;
15
16 import com.quikj.application.communicator.applications.webtalk.model.*;
17 import java.util.*;
18 import java.text.*;
19 import java.net.*;
20 import java.sql.*;
21
22 /**
23  *
24  * @author Vinod Batra
25  */

26 public class TrafficReportForm extends ActionForm
27 {
28     
29     private String JavaDoc startDate;
30     private String JavaDoc endDate;
31     private int width ;
32     private int height;
33     private String JavaDoc groupid ;
34     
35     /** Holds value of property userGroups. */
36     private ArrayList userGroups = new ArrayList();
37     
38     // private String orderBy = "name";
39
/** Creates a new instance of checkParamForm * Calendar/
40      *
41      */

42     public TrafficReportForm()
43     {
44         java.util.Date JavaDoc today = new java.util.Date JavaDoc();
45         SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
46         endDate = formatter.format(today);
47         startDate = formatter.format(today);
48     }
49     
50     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request)
51     {
52         this.height = 600;
53         this.width = 800;
54     }
55     
56     /** Getter for property endDate.
57      * @return Value of property endDate.
58      *
59      */

60     public java.lang.String JavaDoc getEndDate()
61     {
62         return endDate;
63     }
64     
65     /** Setter for property endDate.
66      * @param endDate New value of property endDate.
67      *
68      */

69     public void setEndDate(java.lang.String JavaDoc endDate)
70     {
71         this.endDate = endDate;
72     }
73     
74     /** Getter for property startDate.
75      * @return Value of property startDate.
76      *
77      */

78     public java.lang.String JavaDoc getStartDate()
79     {
80         return startDate;
81     }
82     
83     /** Setter for property startDate.
84      * @param startDate New value of property startDate.
85      *
86      */

87     public void setStartDate(java.lang.String JavaDoc startDate)
88     {
89         this.startDate = startDate;
90     }
91     
92     public int getHeight()
93     {
94         return height;
95     }
96     
97     /** Setter for property graphHeight.
98      * @param graphHeight New value of property graphHeight.
99      *
100      */

101     public void setHeight(int graphHeight)
102     {
103         this.height = graphHeight;
104     }
105     
106     /** Getter for property graphWidth.
107      * @return Value of property graphWidth.
108      *
109      */

110     public int getWidth()
111     {
112         return width;
113     }
114     
115     /** Setter for property graphWidth.
116      * @param graphWidth New value of property graphWidth.
117      *
118      */

119     public void setWidth(int graphWidth)
120     {
121         this.width = graphWidth;
122     }
123     
124     /** Getter for property groupid.
125      * @return Value of property groupid.
126      *
127      */

128     public java.lang.String JavaDoc getGroupid()
129     {
130         return groupid;
131     }
132     
133     /** Setter for property groupid.
134      * @param groupid New value of property groupid.
135      *
136      */

137     public void setGroupid(java.lang.String JavaDoc groupid)
138     {
139         this.groupid = groupid;
140     }
141     
142     /** Getter for property graph_height.
143      * @return Value of property graph_height.
144      *
145      */

146     public ActionErrors validate(ActionMapping mapping,
147     HttpServletRequest JavaDoc request)
148     {
149         ActionErrors errors = new ActionErrors();
150         try
151         {
152         java.sql.Date JavaDoc sd = TrafficDataBean.convertDate(startDate);
153         if (sd == null)
154         {
155             errors.add("startDate", new ActionError("error.Date.format"));
156         }
157         
158         java.sql.Date JavaDoc ed = TrafficDataBean.convertDate(endDate);
159         if (sd == null)
160         {
161             errors.add("endDate", new ActionError("error.Date.format"));
162         }
163         
164         if ((width < 100)|| (width > 1200))
165         {
166             errors.add("width", new ActionError("graph.dimensions"));
167         }
168         
169         if ( (height < 100) || (height > 1200))
170         {
171             
172             errors.add("width", new ActionError("graph.dimensions"));
173         }
174                 
175         if (errors.isEmpty() == false)
176         {
177             GroupTable groups = new GroupTable();
178             Connection c = (Connection)request.getSession().getAttribute("connection");
179             groups.setConnection(c);
180             ArrayList group_list = groups.list();
181             if (group_list != null)
182             {
183                 ArrayList list = new ArrayList();
184                 Iterator iter = group_list.iterator();
185                 
186                 while (iter.hasNext() == true)
187                 {
188                     String JavaDoc group = (String JavaDoc)iter.next();
189                     list.add(new LabelValueBean(group, URLEncoder.encode(group, "UTF-8")));
190                 }
191                 
192                 setUserGroups(list);
193             }
194         }
195         }
196         catch (Exception JavaDoc e)
197         {
198             errors.add("width", new ActionError("error.internal.error"));
199         }
200         return errors;
201         
202     }
203     
204     /** Getter for property userGroups.
205      * @return Value of property userGroups.
206      *
207      */

208     public ArrayList getUserGroups()
209     {
210         return this.userGroups;
211     }
212     
213     /** Setter for property userGroups.
214      * @param userGroups New value of property userGroups.
215      *
216      */

217     public void setUserGroups(ArrayList userGroups)
218     {
219         this.userGroups = userGroups;
220     }
221 }
222
Popular Tags