Source Code Cross Referenced for Set.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.xwork.util.OgnlValueStack;
004:
005:        import java.io.Writer;
006:
007:        /**
008:         * <!-- START SNIPPET: javadoc -->
009:         * <p>The set tag assigns a value to a variable in a specified scope. It is useful when you wish to assign a variable to a
010:         * complex expression and then simply reference that variable each time rather than the complex expression. This is
011:         * useful in both cases: when the complex expression takes time (performance improvement) or is hard to read (code
012:         * readability improvement).</P>
013:         * 
014:         * <p>The set tag accepts body. However the followings need to be take note when using set tag with body</p>
015:         * <ul>
016:         *    <li>body are treated as String and will not be parsed by OGNL</li>
017:         *    <li>body could be scriptlet or JSP tags, the String representation of scriptlet or JSP tags will be used</li>
018:         *    <li>A non-empty will take precedence if there's also a value attribute present, if the body is empty, then the value attribute will be used</li>
019:         * </ul>
020:         *
021:         * <!-- END SNIPPET: javadoc -->
022:         *
023:         * <p/> <b>Parameters</b>
024:         *
025:         * <!-- START SNIPPET: params -->
026:         *
027:         * <ul>
028:         *
029:         * <li>name* (String): The name of the new variable that is assigned the value of <i>value</i></li>
030:         *
031:         * <li>value (Object): The value that is assigned to the variable named <i>name</i></li>
032:         *
033:         * <li>scope (String): The scope in which to assign the variable. Can be <b>application</b>, <b>session</b>,
034:         * <b>request</b>, <b>page</b>, or <b>action</b>. By default it is <b>action</b>.</li>
035:         *
036:         * </ul>
037:         *
038:         * <!-- END SNIPPET: params -->
039:         *
040:         * <p/> <b>Examples</b>
041:         *
042:         * <pre>
043:         * <!-- START SNIPPET: example -->
044:         * &lt;ww:set name="personName" value="person.name"/&gt;
045:         * Hello, &lt;ww:property value="%{#personName}"/&gt;. How are you?
046:         * 
047:         * &lt;ww:set name="personName"&gt;
048:         *   &lt;ww:property value="%{'some string'}" /&gt;
049:         * &lt;/ww:set&gt;
050:         * Hello, &lt;ww:property value="%{#personName}"/&gt;. How are you?
051:         * 
052:         * &lt;ww:set name="personName"&gt;
053:         *    &lt;c:set value="${person.name}" /&gt;
054:         * &lt;/ww:set&gt;
055:         * Hello, &lt;ww:property value="%{#personName}"/&gt;. How are you?
056:         * <!-- END SNIPPET: example -->
057:         * </pre>
058:         *
059:         * @author Patrick Lightbody
060:         * @author Rene Gielen
061:         * @version $Revision: 2871 $
062:         * @since 2.2
063:         *
064:         * @ww.tag name="set" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.SetTag"
065:         * description="Assigns a value to a variable in a specified scope"
066:         */
067:        public class Set extends Component {
068:            protected String name;
069:            protected String scope;
070:            protected String value;
071:
072:            public Set(OgnlValueStack stack) {
073:                super (stack);
074:            }
075:
076:            /**
077:             * Returns true, so that we use EVAL_BODY_BUFFERED instead of EVAL_BODY_INCLUDE
078:             * @see com.opensymphony.webwork.components.Component#usesBody()
079:             */
080:            public boolean usesBody() {
081:                return true;
082:            }
083:
084:            public boolean end(Writer writer, String body) {
085:                OgnlValueStack stack = getStack();
086:
087:                Object o = null;
088:                if (body != null && body.trim().length() > 0) {
089:                    o = body;
090:                    body = ""; // empty the body, we don't want it to be writen out.
091:                } else {
092:                    if (value == null) {
093:                        value = "top";
094:                    }
095:                    o = findValue(value);
096:                }
097:
098:                String name;
099:                if (altSyntax()) {
100:                    name = findString(this .name, "name", "Name is required");
101:                } else {
102:                    name = this .name;
103:
104:                    if (this .name == null) {
105:                        throw fieldError("name", "Name is required", null);
106:                    }
107:                }
108:
109:                if ("application".equalsIgnoreCase(scope)) {
110:                    stack.setValue("#application['" + name + "']", o);
111:                } else if ("session".equalsIgnoreCase(scope)) {
112:                    stack.setValue("#session['" + name + "']", o);
113:                } else if ("request".equalsIgnoreCase(scope)) {
114:                    stack.setValue("#request['" + name + "']", o);
115:                } else if ("page".equalsIgnoreCase(scope)) {
116:                    stack.setValue("#attr['" + name + "']", o, false);
117:                }
118:                //WW-796: SetTag "scope" attribute do not put the object to stack if the scope is given.
119:                stack.getContext().put(name, o);
120:
121:                return super .end(writer, body);
122:            }
123:
124:            /**
125:             * The name of the new variable that is assigned the value of <i>value</i>
126:             * @ww.tagattribute required="true" type="String"
127:             */
128:            public void setName(String name) {
129:                this .name = name;
130:            }
131:
132:            /**
133:             * The scope in which to assign the variable. Can be <b>application</b>, <b>session</b>, <b>request</b>, <b>page</b>, or <b>action</b>.
134:             * @ww.tagattribute required="false" type="String" default="action"
135:             */
136:            public void setScope(String scope) {
137:                this .scope = scope;
138:            }
139:
140:            /**
141:             * The value that is assigned to the variable named <i>name</i>
142:             * @ww.tagattribute required="false"
143:             */
144:            public void setValue(String value) {
145:                this.value = value;
146:            }
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.