1 13 package com.tonbeller.wcf.form; 14 15 import java.io.UnsupportedEncodingException ; 16 import java.util.Date ; 17 18 import org.apache.commons.fileupload.FileItem; 19 20 import com.tonbeller.wcf.controller.RequestContext; 21 22 26 public class TestBean { 27 String stringValue = "some string"; 28 int intValue = 0; 29 Date dateValue = new Date (); 30 Date dateTimeValue = new Date (); 31 double doubleValue = 0.0; 32 String password = ""; 33 34 String textArea; 35 boolean checkBox1; 36 boolean checkBox2; 37 int list1 = 2; 38 int[] listN = new int[]{1, 2}; 39 int dynList = 0; 40 41 boolean radioButton1; 42 boolean radioButton2 = true; 43 44 FileItem fileItem = null; 45 46 47 57 public void testActionReference(RequestContext context) { 58 setTextArea("Form Button pressed!"); 59 System.out.println("Form Button pressed!"); 60 } 61 62 66 public boolean isCheckBox1() { 67 return checkBox1; 68 } 69 70 74 public boolean isCheckBox2() { 75 return checkBox2; 76 } 77 78 82 public Date getDateValue() { 83 return dateValue; 84 } 85 86 90 public int getIntValue() { 91 return intValue; 92 } 93 94 98 public int getList1() { 99 return list1; 100 } 101 102 106 public int[] getListN() { 107 return listN; 108 } 109 110 114 public String getPassword() { 115 return password; 116 } 117 118 122 public String getStringValue() { 123 return stringValue; 124 } 125 126 130 public String getTextArea() { 131 return textArea; 132 } 133 134 138 public void setCheckBox1(boolean checkBox1) { 139 this.checkBox1 = checkBox1; 140 } 141 142 146 public void setCheckBox2(boolean checkBox2) { 147 this.checkBox2 = checkBox2; 148 } 149 150 154 public void setDateValue(Date dateValue) { 155 this.dateValue = dateValue; 156 } 157 158 162 public void setIntValue(int intValue) { 163 this.intValue = intValue; 164 } 165 166 170 public void setList1(int list1) { 171 this.list1 = list1; 172 } 173 174 178 public void setListN(int[] listN) { 179 this.listN = listN; 180 } 181 182 186 public void setPassword(String password) { 187 this.password = password; 188 } 189 190 194 public void setStringValue(String stringValue) { 195 this.stringValue = stringValue; 196 } 197 198 202 public void setTextArea(String textArea) { 203 this.textArea = textArea; 204 } 205 206 210 public boolean isRadioButton1() { 211 return radioButton1; 212 } 213 214 218 public boolean isRadioButton2() { 219 return radioButton2; 220 } 221 222 226 public void setRadioButton1(boolean radioButton1) { 227 this.radioButton1 = radioButton1; 228 } 229 230 234 public void setRadioButton2(boolean radioButton2) { 235 this.radioButton2 = radioButton2; 236 } 237 238 242 public double getDoubleValue() { 243 return doubleValue; 244 } 245 246 250 public void setDoubleValue(double doubleValue) { 251 this.doubleValue = doubleValue; 252 } 253 254 258 public int getDynList() { 259 return dynList; 260 } 261 262 266 public void setDynList(int dynList) { 267 this.dynList = dynList; 268 } 269 270 public Date getDateTimeValue() { 271 return dateTimeValue; 272 } 273 public void setDateTimeValue(Date dateTimeValue) { 274 this.dateTimeValue = dateTimeValue; 275 } 276 277 public FileItem getFileItem() { 278 return fileItem; 279 } 280 281 public void setFileItem(FileItem fileItem) { 282 this.fileItem = fileItem; 283 } 284 285 public String getUploadInfo() throws UnsupportedEncodingException { 286 if(fileItem==null) 287 return "No file received"; 288 289 StringBuffer info = new StringBuffer (); 290 291 info.append("File received: ").append(fileItem.getName()).append("\n"); 292 info.append("Content type: ").append(fileItem.getContentType()).append("\n"); 293 info.append("In Memory: ").append(fileItem.isInMemory()).append("\n"); 296 297 if("text/plain".equals(fileItem.getContentType()) && fileItem.getSize()<1000) 298 info.append("\n").append(fileItem.getString("ISO-8859-1")).append("\n"); 299 300 return info.toString(); 301 } 302 } 303 | Popular Tags |