Source Code Cross Referenced for Param.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:        /*
002:         * Copyright (c) 2002-2006 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.components;
006:
007:        import com.opensymphony.xwork.util.OgnlValueStack;
008:        import com.opensymphony.webwork.WebWorkException;
009:
010:        import java.io.Writer;
011:
012:        /**
013:         * <!-- START SNIPPET: javadoc -->
014:         * <p>This tag can be used to parameterize other tags.</p>
015:         * The include tag and bean tag are examples of such tags.
016:         * <p/>
017:         * The parameters can be added with or without a name as key.
018:         * If the tag provides a name attribute the parameters are added using the
019:         * {@link Component#addParameter(String, Object) addParamter} method.
020:         * For unnamed parameters the Tag must implement the {@link UnnamedParametric} interface defined in
021:         * this class (e.g. The TextTag does this).
022:         * <p/>
023:         * This tag has the following two paramters.
024:         * <!-- START SNIPPET: params -->
025:         * <ul>
026:         * 		<li>name (String) - the name of the parameter</li>
027:         *      <li>value (Object) - the value of the parameter</li>
028:         * </ul>
029:         * <!-- END SNIPPET: params -->
030:         * <p/>
031:         * <b>Note:</b>
032:         * When you declare the param tag, the value can be defined in either a <tt>value</tt> attribute or
033:         * as text between the start and end tag. WebWork behaves a bit different according to these two situations.
034:         * This is best illustrated using an example:
035:         * <br/>&lt;param name="color"&gt;blue&lt;/param&gt; &lt;-- (A) --&gt;
036:         * <br/>&lt;param name="color" value="blue"/&gt; &lt;-- (B) --&gt;
037:         * <br/>In the first situation (A) the value would be evaluated to the stack as a <tt>java.lang.String</tt> object.
038:         * And in situation (B) the value would be evaluated to the stack as a <tt>java.lang.Object</tt> object.
039:         * <br/>For more information see <a href="http://jira.opensymphony.com/browse/WW-808">WW-808</a>.
040:         * <!-- END SNIPPET: javadoc -->
041:         *
042:         * <p/> <b>Examples</b>
043:         * <!-- START SNIPPET: example -->
044:         * <pre>
045:         * &lt;ui:component&gt;
046:         *  &lt;ui:param name="key"     value="[0]"/&gt;
047:         *  &lt;ui:param name="value"   value="[1]"/&gt;
048:         *  &lt;ui:param name="context" value="[2]"/&gt;
049:         * &lt;/ui:component&gt;
050:         * </pre>
051:         * <!-- END SNIPPET: example -->
052:         * <p/>
053:         * <!-- START SNIPPET: exampledescription -->
054:         * where the key will be the identifier and the value the result of an OGNL expression run against the current
055:         * OgnlValueStack.
056:         * <!-- END SNIPPET: exampledescription -->
057:         * <p/>
058:         * This second example demonstrates how the text tag can use parameters from this param tag.
059:         * <!-- START SNIPPET: example2 -->
060:         * <pre>
061:         * &lt;ww:text name="cart.total.cost"&gt;
062:         *     &lt;ww:param value="#session.cartTotal"/&gt;
063:         * &lt;/ww:text&gt;
064:         * </pre>
065:         * <!-- END SNIPPET: example2 -->
066:         * <p/>
067:         *
068:         * @author Rickard �berg (rickard@dreambean.com)
069:         * @author Rene Gielen
070:         * @author tm_jee
071:         * @version $Revision: 2647 $
072:         * @since 2.2
073:         *
074:         * @see Include
075:         * @see Bean
076:         * @see Text
077:         *
078:         * @ww.tag name="param" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ParamTag"
079:         * description="Parametrize other tags"
080:         */
081:        public class Param extends Component {
082:            protected String name;
083:            protected String value;
084:
085:            public Param(OgnlValueStack stack) {
086:                super (stack);
087:            }
088:
089:            public boolean end(Writer writer, String body) {
090:                Component component = findAncestor(Component.class);
091:                if (value != null) {
092:                    if (component instanceof  UnnamedParametric) {
093:                        ((UnnamedParametric) component)
094:                                .addParameter(findValue(value));
095:                    } else {
096:                        String name = findString(this .name);
097:
098:                        if (name == null) {
099:                            throw new WebWorkException(
100:                                    "No name found for following expression: "
101:                                            + name);
102:                        }
103:
104:                        Object value = findValue(this .value);
105:                        component.addParameter(name, value);
106:                    }
107:                } else {
108:                    if (component instanceof  UnnamedParametric) {
109:                        ((UnnamedParametric) component).addParameter(body);
110:                    } else {
111:                        component.addParameter(findString(name), body);
112:                    }
113:                }
114:
115:                return super .end(writer, "");
116:            }
117:
118:            public boolean usesBody() {
119:                return true;
120:            }
121:
122:            /**
123:             * Name of Parameter to set
124:             * @ww.tagattribute required="false" type="String"
125:             */
126:            public void setName(String name) {
127:                this .name = name;
128:            }
129:
130:            /**
131:             * Value expression for Parameter to set
132:             * @ww.tagattribute required="false" default="The value of evaluating provided name against stack"
133:             */
134:            public void setValue(String value) {
135:                this .value = value;
136:            }
137:
138:            /**
139:             * Tags can implement this to support nested param tags without the <tt>name</tt> attribute.
140:             * <p/>
141:             * The {@link Text TextTag} uses this approach. For unnamed parameters an example is given in the class
142:             * javadoc for {@link Param ParamTag}.
143:             */
144:            public interface UnnamedParametric {
145:
146:                /**
147:                 * Adds the given value as a parameter to the outer tag.
148:                 * @param value  the value
149:                 */
150:                public void addParameter(Object value);
151:            }
152:
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.