Source Code Cross Referenced for ConditionalTagSupport.java in  » EJB-Server-GlassFish » appserv-jstl » javax » servlet » jsp » jstl » core » 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 » EJB Server GlassFish » appserv jstl » javax.servlet.jsp.jstl.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         * 
006:         * Portions Copyright Apache Software Foundation.
007:         * 
008:         * The contents of this file are subject to the terms of either the GNU
009:         * General Public License Version 2 only ("GPL") or the Common Development
010:         * and Distribution License("CDDL") (collectively, the "License").  You
011:         * may not use this file except in compliance with the License. You can obtain
012:         * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
013:         * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
014:         * language governing permissions and limitations under the License.
015:         * 
016:         * When distributing the software, include this License Header Notice in each
017:         * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
018:         * Sun designates this particular file as subject to the "Classpath" exception
019:         * as provided by Sun in the GPL Version 2 section of the License file that
020:         * accompanied this code.  If applicable, add the following below the License
021:         * Header, with the fields enclosed by brackets [] replaced by your own
022:         * identifying information: "Portions Copyrighted [year]
023:         * [name of copyright owner]"
024:         * 
025:         * Contributor(s):
026:         * 
027:         * If you wish your version of this file to be governed by only the CDDL or
028:         * only the GPL Version 2, indicate your decision by adding "[Contributor]
029:         * elects to include this software in this distribution under the [CDDL or GPL
030:         * Version 2] license."  If you don't indicate a single choice of license, a
031:         * recipient has the option to distribute your version of this file under
032:         * either the CDDL, the GPL Version 2 or to extend the choice of license to
033:         * its licensees as provided above.  However, if you add GPL Version 2 code
034:         * and therefore, elected the GPL Version 2 license, then the option applies
035:         * only if the new code is made subject to such option by the copyright
036:         * holder.
037:         */
038:
039:        package javax.servlet.jsp.jstl.core;
040:
041:        import javax.servlet.jsp.JspException;
042:        import javax.servlet.jsp.JspTagException;
043:        import javax.servlet.jsp.PageContext;
044:        import javax.servlet.jsp.tagext.TagSupport;
045:
046:        /**
047:         * <p>Abstract class that facilitates implementation of conditional actions 
048:         * where the boolean result is exposed as a JSP scoped variable. The 
049:         * boolean result may then be used as the test condition in a &lt;c:when&gt;
050:         * action.</p>
051:         *
052:         * <p>This base class provides support for:</p>
053:         * 
054:         * <ul>
055:         *  <li> Conditional processing of the action's body based on the returned value
056:         *       of the abstract method <tt>condition()</tt>.</li>
057:         *  <li> Storing the result of <tt>condition()</tt> as a <tt>Boolean</tt> object
058:         *       into a JSP scoped variable identified by attributes <tt>var</tt> and
059:         *       <tt>scope</tt>.
060:         * </ul>
061:         * 
062:         * @author Shawn Bayern
063:         */
064:
065:        public abstract class ConditionalTagSupport extends TagSupport {
066:            //*********************************************************************
067:            // Abstract methods
068:
069:            /**
070:             * <p>Subclasses implement this method to compute the boolean result
071:             * of the conditional action. This method is invoked once per tag invocation 
072:             * by <tt>doStartTag()</tt>.
073:             *
074:             * @return a boolean representing the condition that a particular subclass
075:             *   uses to drive its conditional logic.
076:             */
077:            protected abstract boolean condition() throws JspTagException;
078:
079:            //*********************************************************************
080:            // Constructor
081:
082:            /**
083:             * Base constructor to initialize local state.  As with <tt>TagSupport</tt>,
084:             * subclasses should not implement constructors with arguments, and
085:             * no-argument constructors implemented by subclasses must call the 
086:             * superclass constructor.
087:             */
088:            public ConditionalTagSupport() {
089:                super ();
090:                init();
091:            }
092:
093:            //*********************************************************************
094:            // Lifecycle management and implementation of conditional behavior
095:
096:            /**
097:             * Includes its body if <tt>condition()</tt> evaluates to true.
098:             */
099:            public int doStartTag() throws JspException {
100:
101:                // execute our condition() method once per invocation
102:                result = condition();
103:
104:                // expose variables if appropriate
105:                exposeVariables();
106:
107:                // handle conditional behavior
108:                if (result)
109:                    return EVAL_BODY_INCLUDE;
110:                else
111:                    return SKIP_BODY;
112:            }
113:
114:            /**
115:             * Releases any resources this ConditionalTagSupport may have (or inherit).
116:             */
117:            public void release() {
118:                super .release();
119:                init();
120:            }
121:
122:            //*********************************************************************
123:            // Private state
124:
125:            private boolean result; // the saved result of condition()
126:            private String var; // scoped attribute name
127:            private int scope; // scoped attribute scope
128:
129:            //*********************************************************************
130:            // Accessors
131:
132:            /**
133:             * Sets the 'var' attribute.
134:             *
135:             * @param var Name of the exported scoped variable storing the result of
136:             * <tt>condition()</tt>.
137:             */
138:            public void setVar(String var) {
139:                this .var = var;
140:            }
141:
142:            /**
143:             * Sets the 'scope' attribute.
144:             *
145:             * @param scope Scope of the 'var' attribute
146:             */
147:            public void setScope(String scope) {
148:                if (scope.equalsIgnoreCase("page"))
149:                    this .scope = PageContext.PAGE_SCOPE;
150:                else if (scope.equalsIgnoreCase("request"))
151:                    this .scope = PageContext.REQUEST_SCOPE;
152:                else if (scope.equalsIgnoreCase("session"))
153:                    this .scope = PageContext.SESSION_SCOPE;
154:                else if (scope.equalsIgnoreCase("application"))
155:                    this .scope = PageContext.APPLICATION_SCOPE;
156:                // TODO: Add error handling?  Needs direction from spec.
157:            }
158:
159:            //*********************************************************************
160:            // Utility methods
161:
162:            // expose attributes if we have a non-null 'var'
163:            private void exposeVariables() {
164:                if (var != null)
165:                    pageContext.setAttribute(var, Boolean.valueOf(result),
166:                            scope);
167:            }
168:
169:            // initializes internal state
170:            private void init() {
171:                result = false; // not really necessary
172:                var = null;
173:                scope = PageContext.PAGE_SCOPE;
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.