Source Code Cross Referenced for Push.java in  » Web-Framework » struts-2.0.11 » org » apache » struts2 » 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 » Web Framework » struts 2.0.11 » org.apache.struts2.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: Push.java 497654 2007-01-19 00:21:57Z rgielen $
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:        package org.apache.struts2.components;
022:
023:        import java.io.Writer;
024:
025:        import org.apache.struts2.views.annotations.StrutsTag;
026:        import org.apache.struts2.views.annotations.StrutsTagAttribute;
027:
028:        import com.opensymphony.xwork2.util.ValueStack;
029:
030:        /**
031:         * <!-- START SNIPPET: javadoc -->
032:         * <p>Push value on stack for simplified usage.</p>
033:         * <!-- END SNIPPET: javadoc -->
034:         *
035:         * <!-- START SNIPPET: params -->
036:         * <ul>
037:         *      <li>value* (Object) - value to be pushed into the top of the stack</li>
038:         * </ul>
039:         * <!-- END SNIPPET: params -->
040:         *
041:         *
042:         * <p/> <b>Examples</b>
043:         * <pre>
044:         * <!-- START SNIPPET: example1 -->
045:         * &lt;s:push value="user"&gt;
046:         *     &lt;s:propery value="firstName" /&gt;
047:         *     &lt;s:propery value="lastName" /&gt;
048:         * &lt;/s:push&gt;
049:         * <!-- END SNIPPET: example1 -->
050:         * </pre>
051:         *
052:         * <!-- START SNIPPET: example1description -->
053:         * Pushed user into the stack, and hence property tag could access user's properties
054:         * (firstName, lastName etc) since user is not at the top of the stack
055:         * <!-- END SNIPPET: example1description -->
056:         *
057:         * <pre>
058:         * <!-- START SNIPPET: example2 -->
059:         *  &lt;s:push value="myObject"&gt;                              ----- (1)
060:         *       &lt;s:bean name="jp.SomeBean" id="myBean"/&gt;        ----- (2)
061:         *          &lt;s:param name="myParam" value="top"/&gt;        ----- (3)
062:         *       &lt;/s:bean&gt;
063:         *   &lt;/s:push&gt;
064:         * <!-- END SNIPPET: example2 -->
065:         * </pre>
066:         *
067:         * <pre>
068:         * <!-- START SNIPPET: example2description -->
069:         * when in (1), myObject is at the top of the stack
070:         * when in (2), jp.SomeBean is in the top of stack, also in stack's context with key myBean
071:         * when in (3), top will get the jp.SomeBean instance
072:         * <!-- END SNIPPET: example2description -->
073:         * </pre>
074:         *
075:         * <pre>
076:         * <!-- START SNIPPET: example3 -->
077:         * &lt;s:push value="myObject"&gt;                                       ---(A)
078:         *    &lt;s:bean name="jp.SomeBean" id="myBean"/&gt;                   ---(B)
079:         *       &lt;s:param name="myParam" value="top.mySomeOtherValue"/&gt;  ---(C)
080:         *    &lt;/s:bean&gt;
081:         * &lt;/s:push&gt;
082:         * <!-- END SNIPPET: example3 -->
083:         * </pre>
084:         *
085:         * <pre>
086:         * <!-- START SNIPPET: example3description -->
087:         * when in (A), myObject is at the top of the stack
088:         * when in (B), jp.SomeBean is at the top of the stack, also in context with key myBean
089:         * when in (C), top refers to jp.SomeBean instance. so top.mySomeOtherValue would invoke SomeBean's mySomeOtherValue() method
090:         * <!-- END SNIPPET: example3description -->
091:         * </pre>
092:         *
093:         * <pre>
094:         * <!-- START SNIPPET: example4 -->
095:         * &lt;s:push value="myObject"&gt;                                 ---- (i)
096:         *    &lt;s:bean name="jp.SomeBean" id="myBean"/&gt;             ---- (ii)
097:         *       &lt;s:param name="myParam" value="[1].top"/&gt;         -----(iii)
098:         *    &lt;/s:bean&gt;
099:         * &lt;/s:push&gt;
100:         * <!-- END SNIPPET: example4 -->
101:         * </pre>
102:         *
103:         * <pre>
104:         * <!-- START SNIPPET: example4description -->
105:         * when in (i), myObject is at the top of the stack
106:         * when in (ii), jp.SomeBean is at the top of the stack, followed by myObject
107:         * when in (iii), [1].top will returned top of the cut of stack starting from myObject, namely myObject itself
108:         * <!-- END SNIPPET: example4description -->
109:         * </pre>
110:         *
111:         */
112:        @StrutsTag(name="push",tldTagClass="org.apache.struts2.views.jsp.PushTag",description="Push value on stack for simplified usage.")
113:        public class Push extends Component {
114:            protected String value;
115:            protected boolean pushed;
116:
117:            public Push(ValueStack stack) {
118:                super (stack);
119:            }
120:
121:            public boolean start(Writer writer) {
122:                boolean result = super .start(writer);
123:
124:                ValueStack stack = getStack();
125:
126:                if (stack != null) {
127:                    stack
128:                            .push(findValue(value, "value",
129:                                    "You must specify a value to push on the stack. Example: person"));
130:                    pushed = true;
131:                } else {
132:                    pushed = false; // need to ensure push is assigned, otherwise we may have a leftover value
133:                }
134:
135:                return result;
136:            }
137:
138:            public boolean end(Writer writer, String body) {
139:                ValueStack stack = getStack();
140:
141:                if (pushed && (stack != null)) {
142:                    stack.pop();
143:                }
144:
145:                return super .end(writer, body);
146:            }
147:
148:            @StrutsTagAttribute(description="Value to push on stack",required=true)
149:            public void setValue(String value) {
150:                this.value = value;
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.