KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > form > TestBean


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.form;
14
15 import java.io.UnsupportedEncodingException JavaDoc;
16 import java.util.Date JavaDoc;
17
18 import org.apache.commons.fileupload.FileItem;
19
20 import com.tonbeller.wcf.controller.RequestContext;
21
22 /**
23  * Bean containing test data
24  * @author av
25  */

26 public class TestBean {
27   String JavaDoc stringValue = "some string";
28   int intValue = 0;
29   Date JavaDoc dateValue = new Date JavaDoc();
30   Date JavaDoc dateTimeValue = new Date JavaDoc();
31   double doubleValue = 0.0;
32   String JavaDoc password = "";
33
34   String JavaDoc 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   /**
48    * this method is called when the user presses a button and
49    * the requested validation succeeded. This means, that all properties
50    * have their new values from user input.
51    * <p />
52    * The method name is specified by the <tt>actionReference</tt> attribute
53    * of the DOM element representing the button.
54    *
55    * @param context
56    */

57   public void testActionReference(RequestContext context) {
58     setTextArea("Form Button pressed!");
59     System.out.println("Form Button pressed!");
60   }
61
62   /**
63    * Returns the checkBox1.
64    * @return boolean
65    */

66   public boolean isCheckBox1() {
67     return checkBox1;
68   }
69
70   /**
71    * Returns the checkBox2.
72    * @return boolean
73    */

74   public boolean isCheckBox2() {
75     return checkBox2;
76   }
77
78   /**
79    * Returns the dateValue.
80    * @return Date
81    */

82   public Date JavaDoc getDateValue() {
83     return dateValue;
84   }
85
86   /**
87    * Returns the intValue.
88    * @return int
89    */

90   public int getIntValue() {
91     return intValue;
92   }
93
94   /**
95    * Returns the list1.
96    * @return int
97    */

98   public int getList1() {
99     return list1;
100   }
101
102   /**
103    * Returns the listN.
104    * @return int[]
105    */

106   public int[] getListN() {
107     return listN;
108   }
109
110   /**
111    * Returns the password.
112    * @return String
113    */

114   public String JavaDoc getPassword() {
115     return password;
116   }
117
118   /**
119    * Returns the stringValue.
120    * @return String
121    */

122   public String JavaDoc getStringValue() {
123     return stringValue;
124   }
125
126   /**
127    * Returns the textArea.
128    * @return String
129    */

130   public String JavaDoc getTextArea() {
131     return textArea;
132   }
133
134   /**
135    * Sets the checkBox1.
136    * @param checkBox1 The checkBox1 to set
137    */

138   public void setCheckBox1(boolean checkBox1) {
139     this.checkBox1 = checkBox1;
140   }
141
142   /**
143    * Sets the checkBox2.
144    * @param checkBox2 The checkBox2 to set
145    */

146   public void setCheckBox2(boolean checkBox2) {
147     this.checkBox2 = checkBox2;
148   }
149
150   /**
151    * Sets the dateValue.
152    * @param dateValue The dateValue to set
153    */

154   public void setDateValue(Date JavaDoc dateValue) {
155     this.dateValue = dateValue;
156   }
157
158   /**
159    * Sets the intValue.
160    * @param intValue The intValue to set
161    */

162   public void setIntValue(int intValue) {
163     this.intValue = intValue;
164   }
165
166   /**
167    * Sets the list1.
168    * @param list1 The list1 to set
169    */

170   public void setList1(int list1) {
171     this.list1 = list1;
172   }
173
174   /**
175    * Sets the listN.
176    * @param listN The listN to set
177    */

178   public void setListN(int[] listN) {
179     this.listN = listN;
180   }
181
182   /**
183    * Sets the password.
184    * @param password The password to set
185    */

186   public void setPassword(String JavaDoc password) {
187     this.password = password;
188   }
189
190   /**
191    * Sets the stringValue.
192    * @param stringValue The stringValue to set
193    */

194   public void setStringValue(String JavaDoc stringValue) {
195     this.stringValue = stringValue;
196   }
197
198   /**
199    * Sets the textArea.
200    * @param textArea The textArea to set
201    */

202   public void setTextArea(String JavaDoc textArea) {
203     this.textArea = textArea;
204   }
205
206   /**
207    * Returns the radioButton1.
208    * @return boolean
209    */

210   public boolean isRadioButton1() {
211     return radioButton1;
212   }
213
214   /**
215    * Returns the radioButton2.
216    * @return boolean
217    */

218   public boolean isRadioButton2() {
219     return radioButton2;
220   }
221
222   /**
223    * Sets the radioButton1.
224    * @param radioButton1 The radioButton1 to set
225    */

226   public void setRadioButton1(boolean radioButton1) {
227     this.radioButton1 = radioButton1;
228   }
229
230   /**
231    * Sets the radioButton2.
232    * @param radioButton2 The radioButton2 to set
233    */

234   public void setRadioButton2(boolean radioButton2) {
235     this.radioButton2 = radioButton2;
236   }
237
238   /**
239    * Returns the doubleValue.
240    * @return double
241    */

242   public double getDoubleValue() {
243     return doubleValue;
244   }
245
246   /**
247    * Sets the doubleValue.
248    * @param doubleValue The doubleValue to set
249    */

250   public void setDoubleValue(double doubleValue) {
251     this.doubleValue = doubleValue;
252   }
253
254   /**
255    * Returns the dynList.
256    * @return int
257    */

258   public int getDynList() {
259     return dynList;
260   }
261
262   /**
263    * Sets the dynList.
264    * @param dynList The dynList to set
265    */

266   public void setDynList(int dynList) {
267     this.dynList = dynList;
268   }
269
270   public Date JavaDoc getDateTimeValue() {
271     return dateTimeValue;
272   }
273   public void setDateTimeValue(Date JavaDoc 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 JavaDoc getUploadInfo() throws UnsupportedEncodingException JavaDoc {
286     if(fileItem==null)
287       return "No file received";
288
289     StringBuffer JavaDoc info = new StringBuffer JavaDoc();
290
291     info.append("File received: ").append(fileItem.getName()).append("\n");
292     info.append("Content type: ").append(fileItem.getContentType()).append("\n");
293     // Size unterschiedlich auf Linux/Windows
294
//info.append("Size: ").append(fileItem.getSize()).append("\n");
295
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