Source Code Cross Referenced for TestBean.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » webapp » el » exercise » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » struts 1.3.8 » org.apache.struts.webapp.el.exercise 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: TestBean.java 471754 2006-11-06 14:55:09Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        package org.apache.struts.webapp.el.exercise;
023:
024:        import org.apache.struts.action.ActionForm;
025:        import org.apache.struts.action.ActionMapping;
026:        import org.apache.struts.util.LabelValueBean;
027:
028:        import javax.servlet.http.HttpServletRequest;
029:        import java.util.Collection;
030:        import java.util.Vector;
031:
032:        /**
033:         * General purpose test bean for Struts custom tag tests.
034:         *
035:         * @author Craig R. McClanahan
036:         * @author Martin F N Cooper
037:         * @version $Rev: 471754 $ $Date: 2004-10-16 13:04:52 -0400 (Sat, 16 Oct 2004)
038:         *          $
039:         */
040:
041:        public class TestBean extends ActionForm {
042:
043:            // ------------------------------------------------------------- Properties
044:
045:            /**
046:             * A collection property where the elements of the collection are of type
047:             * <code>LabelValueBean</code>.
048:             */
049:            private Collection beanCollection = null;
050:
051:            public Collection getBeanCollection() {
052:                if (beanCollection == null) {
053:                    Vector entries = new Vector(10);
054:
055:                    entries.add(new LabelValueBean("Label 0", "Value 0"));
056:                    entries.add(new LabelValueBean("Label 1", "Value 1"));
057:                    entries.add(new LabelValueBean("Label 2", "Value 2"));
058:                    entries.add(new LabelValueBean("Label 3", "Value 3"));
059:                    entries.add(new LabelValueBean("Label 4", "Value 4"));
060:                    entries.add(new LabelValueBean("Label 5", "Value 5"));
061:                    entries.add(new LabelValueBean("Label 6", "Value 6"));
062:                    entries.add(new LabelValueBean("Label 7", "Value 7"));
063:                    entries.add(new LabelValueBean("Label 8", "Value 8"));
064:                    entries.add(new LabelValueBean("Label 9", "Value 9"));
065:
066:                    beanCollection = entries;
067:                }
068:
069:                return (beanCollection);
070:            }
071:
072:            public void setBeanCollection(Collection beanCollection) {
073:                this .beanCollection = beanCollection;
074:            }
075:
076:            /**
077:             * A multiple-String SELECT element using a bean collection.
078:             */
079:            private String[] beanCollectionSelect = { "Value 1", "Value 3",
080:                    "Value 5" };
081:
082:            public String[] getBeanCollectionSelect() {
083:                return (this .beanCollectionSelect);
084:            }
085:
086:            public void setBeanCollectionSelect(String beanCollectionSelect[]) {
087:                this .beanCollectionSelect = beanCollectionSelect;
088:            }
089:
090:            /**
091:             * A boolean property whose initial value is true.
092:             */
093:            private boolean booleanProperty = true;
094:
095:            public boolean getBooleanProperty() {
096:                return (booleanProperty);
097:            }
098:
099:            public void setBooleanProperty(boolean booleanProperty) {
100:                this .booleanProperty = booleanProperty;
101:            }
102:
103:            /**
104:             * A multiple-String SELECT element using a collection.
105:             */
106:            private String[] collectionSelect = { "Value 2", "Value 4",
107:                    "Value 6" };
108:
109:            public String[] getCollectionSelect() {
110:                return (this .collectionSelect);
111:            }
112:
113:            public void setCollectionSelect(String collectionSelect[]) {
114:                this .collectionSelect = collectionSelect;
115:            }
116:
117:            /**
118:             * A double property.
119:             */
120:            private double doubleProperty = 321.0;
121:
122:            public double getDoubleProperty() {
123:                return (this .doubleProperty);
124:            }
125:
126:            public void setDoubleProperty(double doubleProperty) {
127:                this .doubleProperty = doubleProperty;
128:            }
129:
130:            /**
131:             * A boolean property whose initial value is false
132:             */
133:            private boolean falseProperty = false;
134:
135:            public boolean getFalseProperty() {
136:                return (falseProperty);
137:            }
138:
139:            public void setFalseProperty(boolean falseProperty) {
140:                this .falseProperty = falseProperty;
141:            }
142:
143:            /**
144:             * A float property.
145:             */
146:            private float floatProperty = (float) 123.0;
147:
148:            public float getFloatProperty() {
149:                return (this .floatProperty);
150:            }
151:
152:            public void setFloatProperty(float floatProperty) {
153:                this .floatProperty = floatProperty;
154:            }
155:
156:            /**
157:             * Integer arrays that are accessed as an array as well as indexed.
158:             */
159:            private int intArray[] = { 0, 10, 20, 30, 40 };
160:
161:            public int[] getIntArray() {
162:                return (this .intArray);
163:            }
164:
165:            public void setIntArray(int intArray[]) {
166:                this .intArray = intArray;
167:            }
168:
169:            private int intIndexed[] = { 0, 10, 20, 30, 40 };
170:
171:            public int getIntIndexed(int index) {
172:                return (intIndexed[index]);
173:            }
174:
175:            public void setIntIndexed(int index, int value) {
176:                intIndexed[index] = value;
177:            }
178:
179:            private int intMultibox[] = new int[0];
180:
181:            public int[] getIntMultibox() {
182:                return (this .intMultibox);
183:            }
184:
185:            public void setIntMultibox(int intMultibox[]) {
186:                this .intMultibox = intMultibox;
187:            }
188:
189:            /**
190:             * An integer property.
191:             */
192:            private int intProperty = 123;
193:
194:            public int getIntProperty() {
195:                return (this .intProperty);
196:            }
197:
198:            public void setIntProperty(int intProperty) {
199:                this .intProperty = intProperty;
200:            }
201:
202:            /**
203:             * A long property.
204:             */
205:            private long longProperty = 321;
206:
207:            public long getLongProperty() {
208:                return (this .longProperty);
209:            }
210:
211:            public void setLongProperty(long longProperty) {
212:                this .longProperty = longProperty;
213:            }
214:
215:            /**
216:             * A multiple-String SELECT element.
217:             */
218:            private String[] multipleSelect = { "Multiple 3", "Multiple 5",
219:                    "Multiple 7" };
220:
221:            public String[] getMultipleSelect() {
222:                return (this .multipleSelect);
223:            }
224:
225:            public void setMultipleSelect(String multipleSelect[]) {
226:                this .multipleSelect = multipleSelect;
227:            }
228:
229:            /**
230:             * A nested reference to another test bean (populated as needed).
231:             */
232:            private TestBean nested = null;
233:
234:            public TestBean getNested() {
235:                if (nested == null) {
236:                    nested = new TestBean();
237:                }
238:                return (nested);
239:            }
240:
241:            /**
242:             * A String property with an initial value of null.
243:             */
244:            private String nullProperty = null;
245:
246:            public String getNullProperty() {
247:                return (this .nullProperty);
248:            }
249:
250:            public void setNullProperty(String nullProperty) {
251:                this .nullProperty = nullProperty;
252:            }
253:
254:            /**
255:             * A short property.
256:             */
257:            private short shortProperty = (short) 987;
258:
259:            public short getShortProperty() {
260:                return (this .shortProperty);
261:            }
262:
263:            public void setShortProperty(short shortProperty) {
264:                this .shortProperty = shortProperty;
265:            }
266:
267:            /**
268:             * A single-String value for a SELECT element.
269:             */
270:            private String singleSelect = "Single 5";
271:
272:            public String getSingleSelect() {
273:                return (this .singleSelect);
274:            }
275:
276:            public void setSingleSelect(String singleSelect) {
277:                this .singleSelect = singleSelect;
278:            }
279:
280:            /**
281:             * String arrays that are accessed as an array as well as indexed.
282:             */
283:            private String stringArray[] = { "String 0", "String 1",
284:                    "String 2", "String 3", "String 4" };
285:
286:            public String[] getStringArray() {
287:                return (this .stringArray);
288:            }
289:
290:            public void setStringArray(String stringArray[]) {
291:                this .stringArray = stringArray;
292:            }
293:
294:            private String stringIndexed[] = { "String 0", "String 1",
295:                    "String 2", "String 3", "String 4" };
296:
297:            public String getStringIndexed(int index) {
298:                return (stringIndexed[index]);
299:            }
300:
301:            public void setStringIndexed(int index, String value) {
302:                stringIndexed[index] = value;
303:            }
304:
305:            private String indexedStrings[] = { "alpha", "beta", "gamma",
306:                    "delta", "epsilon" };
307:
308:            public String[] getIndexedStrings() {
309:                return (indexedStrings);
310:            }
311:
312:            private String stringMultibox[] = new String[0];
313:
314:            public String[] getStringMultibox() {
315:                return (this .stringMultibox);
316:            }
317:
318:            public void setStringMultibox(String stringMultibox[]) {
319:                this .stringMultibox = stringMultibox;
320:            }
321:
322:            /**
323:             * A String property.
324:             */
325:            private String stringProperty = "This is a string";
326:
327:            public String getStringProperty() {
328:                return (this .stringProperty);
329:            }
330:
331:            public void setStringProperty(String stringProperty) {
332:                this .stringProperty = stringProperty;
333:            }
334:
335:            /**
336:             * An empty String property.
337:             */
338:            private String emptyStringProperty = "";
339:
340:            public String getEmptyStringProperty() {
341:                return (this .emptyStringProperty);
342:            }
343:
344:            public void setEmptyStringProperty(String emptyStringProperty) {
345:                this .emptyStringProperty = emptyStringProperty;
346:            }
347:
348:            /**
349:             * A list of coordinate objects.
350:             */
351:            private Coord[] coords = { new Coord(0, 0), new Coord(0, 1),
352:                    new Coord(1, 1), new Coord(2, 0), new Coord(2, 1) };
353:
354:            public Coord[] getCoords() {
355:                return (coords);
356:            }
357:
358:            public Coord getCoord(int index) {
359:                return (coords[index]);
360:            }
361:
362:            public void setCoord(int index, Coord coord) {
363:                coords[index] = coord;
364:            }
365:
366:            /**
367:             * A list of images.
368:             */
369:            public String images[] = { "T1.gif", "T2.gif" };
370:
371:            public String[] getImages() {
372:                return (images);
373:            }
374:
375:            private Coord[] imageCoords = { new Coord(0, 0), new Coord(0, 0) };
376:
377:            public Coord[] getImageCoords() {
378:                return (imageCoords);
379:            }
380:
381:            public Coord getImageCoord(int index) {
382:                return (imageCoords[index]);
383:            }
384:
385:            public void setImageCoord(int index, Coord coord) {
386:                imageCoords[index] = coord;
387:            }
388:
389:            /**
390:             * A property that allows a null value but is still used in a SELECT.
391:             */
392:            private String withNulls = null;
393:
394:            public String getWithNulls() {
395:                return (this .withNulls);
396:            }
397:
398:            public void setWithNulls(String withNulls) {
399:                this .withNulls = withNulls;
400:            }
401:
402:            // --------------------------------------------------------- Public Methods
403:
404:            /**
405:             * Reset the properties that will be received as input.
406:             */
407:            public void reset(ActionMapping mapping, HttpServletRequest request) {
408:
409:                booleanProperty = false;
410:                collectionSelect = new String[0];
411:                intMultibox = new int[0];
412:                multipleSelect = new String[0];
413:                stringMultibox = new String[0];
414:                if (nested != null) {
415:                    nested.reset(mapping, request);
416:                }
417:
418:            }
419:
420:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.