1 6 7 package com.quikj.application.communicator.applications.webtalk.controller; 8 9 import javax.servlet.http.HttpServletRequest ; 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 26 public class TrafficReportForm extends ActionForm 27 { 28 29 private String startDate; 30 private String endDate; 31 private int width ; 32 private int height; 33 private String groupid ; 34 35 36 private ArrayList userGroups = new ArrayList(); 37 38 42 public TrafficReportForm() 43 { 44 java.util.Date today = new java.util.Date (); 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 request) 51 { 52 this.height = 600; 53 this.width = 800; 54 } 55 56 60 public java.lang.String getEndDate() 61 { 62 return endDate; 63 } 64 65 69 public void setEndDate(java.lang.String endDate) 70 { 71 this.endDate = endDate; 72 } 73 74 78 public java.lang.String getStartDate() 79 { 80 return startDate; 81 } 82 83 87 public void setStartDate(java.lang.String startDate) 88 { 89 this.startDate = startDate; 90 } 91 92 public int getHeight() 93 { 94 return height; 95 } 96 97 101 public void setHeight(int graphHeight) 102 { 103 this.height = graphHeight; 104 } 105 106 110 public int getWidth() 111 { 112 return width; 113 } 114 115 119 public void setWidth(int graphWidth) 120 { 121 this.width = graphWidth; 122 } 123 124 128 public java.lang.String getGroupid() 129 { 130 return groupid; 131 } 132 133 137 public void setGroupid(java.lang.String groupid) 138 { 139 this.groupid = groupid; 140 } 141 142 146 public ActionErrors validate(ActionMapping mapping, 147 HttpServletRequest request) 148 { 149 ActionErrors errors = new ActionErrors(); 150 try 151 { 152 java.sql.Date sd = TrafficDataBean.convertDate(startDate); 153 if (sd == null) 154 { 155 errors.add("startDate", new ActionError("error.Date.format")); 156 } 157 158 java.sql.Date 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 group = (String )iter.next(); 189 list.add(new LabelValueBean(group, URLEncoder.encode(group, "UTF-8"))); 190 } 191 192 setUserGroups(list); 193 } 194 } 195 } 196 catch (Exception e) 197 { 198 errors.add("width", new ActionError("error.internal.error")); 199 } 200 return errors; 201 202 } 203 204 208 public ArrayList getUserGroups() 209 { 210 return this.userGroups; 211 } 212 213 217 public void setUserGroups(ArrayList userGroups) 218 { 219 this.userGroups = userGroups; 220 } 221 } 222 | Popular Tags |