Source Code Cross Referenced for ListUIBean.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » components » 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 » J2EE » webwork 2.2.6 » com.opensymphony.webwork.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.opensymphony.webwork.components;
002:
003:        import com.opensymphony.webwork.util.ContainUtil;
004:        import com.opensymphony.webwork.util.MakeIterator;
005:        import com.opensymphony.xwork.util.OgnlValueStack;
006:
007:        import javax.servlet.http.HttpServletRequest;
008:        import javax.servlet.http.HttpServletResponse;
009:        import java.lang.reflect.Array;
010:        import java.util.Collection;
011:        import java.util.Map;
012:
013:        /**
014:         * DoubleListUIBean is the standard superclass of all webwork list handling components.
015:         *
016:         * <p/>
017:         * 
018:         * <!-- START SNIPPET: javadoc -->
019:         * 
020:         * Note that the listkey and listvalue attribute will default to "key" and "value"
021:         * respectively only when the list attribute is evaluated to a Map or its decendant.
022:         * Other thing else, will result in listkey and listvalue to be null and not used.
023:         * 
024:         * <!-- END SNIPPET: javadoc -->
025:         *
026:         *
027:         * @author Patrick Lightbody
028:         * @author Rene Gielen
029:         * @version $Revision: 2699 $
030:         * @since 2.2
031:         */
032:        public abstract class ListUIBean extends UIBean {
033:            protected Object list;
034:            protected String listKey;
035:            protected String listValue;
036:
037:            // indicate if an exception is to be thrown when value attribute is null
038:            protected boolean throwExceptionOnNullValueAttribute = false;
039:
040:            protected ListUIBean(OgnlValueStack stack,
041:                    HttpServletRequest request, HttpServletResponse response) {
042:                super (stack, request, response);
043:            }
044:
045:            public void evaluateExtraParams() {
046:                Object value = null;
047:
048:                if (list == null) {
049:                    list = parameters.get("list");
050:                }
051:
052:                if (list instanceof  String) {
053:                    value = findValue((String) list);
054:                } else if (list instanceof  Collection) {
055:                    value = list;
056:                } else if (MakeIterator.isIterable(list)) {
057:                    value = MakeIterator.convert(list);
058:                }
059:                if (value == null) {
060:                    if (throwExceptionOnNullValueAttribute) {
061:                        // will throw an exception if not found
062:                        value = findValue(
063:                                (list == null) ? (String) list : list
064:                                        .toString(),
065:                                "list",
066:                                "The requested list key '"
067:                                        + list
068:                                        + "' could not be resolved as a collection/array/map/enumeration/iterator type. "
069:                                        + "Example: people or people.{name}");
070:                    } else {
071:                        // ww-1010, allows value with null value to be compatible with ww 
072:                        // 2.1.7 behaviour
073:                        value = findValue((list == null) ? (String) list : list
074:                                .toString());
075:                    }
076:                }
077:
078:                if (value instanceof  Collection) {
079:                    addParameter("list", value);
080:                } else {
081:                    addParameter("list", MakeIterator.convert(value));
082:                }
083:
084:                if (value instanceof  Collection) {
085:                    addParameter("listSize", new Integer(((Collection) value)
086:                            .size()));
087:                } else if (value instanceof  Map) {
088:                    addParameter("listSize", new Integer(((Map) value).size()));
089:                } else if (value != null && value.getClass().isArray()) {
090:                    addParameter("listSize",
091:                            new Integer(Array.getLength(value)));
092:                }
093:
094:                if (listKey != null) {
095:                    addParameter("listKey", listKey);
096:                } else if (value instanceof  Map) {
097:                    addParameter("listKey", "key");
098:                }
099:
100:                if (listValue != null) {
101:
102:                    if (altSyntax()) {
103:                        // the same logic as with findValue(String)
104:                        // if value start with %{ and end with }, just cut it off!
105:                        if (listValue.startsWith("%{")
106:                                && listValue.endsWith("}")) {
107:                            listValue = listValue.substring(2, listValue
108:                                    .length() - 1);
109:                        }
110:                    }
111:
112:                    addParameter("listValue", listValue);
113:                } else if (value instanceof  Map) {
114:                    addParameter("listValue", "value");
115:                }
116:            }
117:
118:            public boolean contains(Object obj1, Object obj2) {
119:                return ContainUtil.contains(obj1, obj2);
120:            }
121:
122:            protected Class getValueClassType() {
123:                return null; // don't convert nameValue to anything, we need the raw value
124:            }
125:
126:            /**
127:             * Iterable source to populate from. If the list is a Map (key, value), the Map key will become the option "value" parameter and the Map value will become the option body.
128:             * @ww.tagattribute required="true"
129:             */
130:            public void setList(Object list) {
131:                this .list = list;
132:            }
133:
134:            /**
135:             * Property of list objects to get field value from
136:             * @ww.tagattribute required="false"
137:             */
138:            public void setListKey(String listKey) {
139:                this .listKey = listKey;
140:            }
141:
142:            /**
143:             * Property of list objects to get field content from
144:             * @ww.tagattribute required="false"
145:             */
146:            public void setListValue(String listValue) {
147:                this .listValue = listValue;
148:            }
149:
150:            public void setThrowExceptionOnNullValueAttribute(
151:                    boolean throwExceptionOnNullValueAttribute) {
152:                this.throwExceptionOnNullValueAttribute = throwExceptionOnNullValueAttribute;
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.