Source Code Cross Referenced for SetAttribute.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » template » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.netui.tags.template 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         *
017:         * $Header:$
018:         */
019:        package org.apache.beehive.netui.tags.template;
020:
021:        import org.apache.beehive.netui.tags.AbstractClassicTag;
022:
023:        import javax.servlet.ServletRequest;
024:        import javax.servlet.jsp.JspException;
025:        import java.util.HashMap;
026:
027:        /**
028:         * Set an <code>Attribute</code> value defined in a template.  This tag is
029:         * used in content pages to set the value of attributes defined in a template.
030:         * The attribute value will override any default value defined on the
031:         * <code>Attribute</code>.
032:
033:         * @jsptagref.tagdescription
034:         * 
035:         * Sets a property value in a template page.
036:         * 
037:         * <p>The &lt;netui-template:setAttribute> tag must have a parent 
038:         * {@link Template} tag.
039:         * 
040:         * <p>The target placeholder is defined by a {@link Attribute} tag.  For a value to be set
041:         * in the placeholder, the &lt;netui-template:attribute> and 
042:         * &lt;netui-template:setAttribute> tags must have matching <code>name</code> attributes.
043:         * 
044:         * <p>For example, a placeholder may be defined 
045:         * in the template.
046:         * 
047:         * <p><b>In the template JSP page...</b>
048:         * 
049:         * <pre>    &lt;head>
050:         *        &lt;title>
051:         *            &lt;netui-template:attribute name="title"/>
052:         *        &lt;/title>
053:         *    &lt;/head></pre> 
054:         * 
055:         * <p>Then content pages may set the value of this placeholder using the 
056:         * &lt;netui-template:setAttribute> tag.
057:         * 
058:         * <p><b>In a content JSP page...</b>
059:         * 
060:         * <pre>    &lt;netui-template:setAttribute name="title" value="myContentPage1.jsp"/></pre>
061:         * 
062:         * <p>The HTML rendered in the browser appears as follows.
063:         * 
064:         * <p><b>Rendered HTML in the browser...</b>
065:         * 
066:         * <pre>    &lt;head>
067:         *        &lt;title>
068:         *            myContentPage1.jsp
069:         *        &lt;/title>
070:         *    &lt;/head></pre>
071:         * 
072:         * If the &lt;netui-template:setAttribute> tag specifies no value to be set in the placeholder, then the
073:         * &lt;netui-template:attribute> tag's <code>defaultValue</code> will be used.
074:         * 
075:         * <pre>    &lt;netui-template:attribute name="title" <b>defaultValue="My Page"</b>/></pre>
076:         * 
077:         * The &lt;netui-template:attribute> tag may also be used to define placeholders within 
078:         * JSP and HTML tags.
079:         * 
080:         * <p><b>In the template JSP page...</b>
081:         * 
082:         * <pre>    &lt;td colspan="3" bgcolor="<b>&lt;netui-template:attribute name="headerColor" defaultValue="#ffffff"/></b>"></pre>
083:         * 
084:         * @example 
085:         * <p>Assume a &lt;netui-template:attribute&gt; tag defines a value placeholder 
086:         * within a &lt;td> tag</p>
087:         * 
088:         * <pre>    &lt;td colspan="3" bgcolor="<b>&lt;netui-template:attribute name="headerColor" defaultValue="#ffffff"/></b>"></pre>
089:         * 
090:         * <p>Now a content JSP page can control the background color of the &lt;td>.
091:         * 
092:         * <pre>    &lt;netui-template:setAttribute name="headerColor" value="lightgreen"/></pre>
093:         * 
094:         * The HTML rendered in the browser will appear as follows.
095:         * 
096:         * <pre>    &lt;td colspan="3" bgcolor="lightgreen"></pre>
097:         *    
098:         * @netui:tag name="setAttribute"
099:         *          description="Use this tag to set the value of an netui-template:attribute element in a template file."
100:         */
101:        public class SetAttribute extends AbstractClassicTag implements 
102:                TemplateConstants {
103:            /**
104:             * The name of the attribute.
105:             */
106:            private String _name;
107:
108:            /**
109:             * The value of the attribute.
110:             */
111:            private String _value;
112:
113:            /**
114:             * Return the name of the tag.  This is used by error reporting
115:             * in the base class <code>AbstractBaseTag</code>.
116:             */
117:            public String getTagName() {
118:                return "SetAttribute";
119:            }
120:
121:            /**
122:             * Set the <code>name</code> of the attribute.
123:             * @param name The name of the <code>Attribute</code> in the
124:             *  template for which this tags sets the value.
125:             *
126:             * @jsptagref.attributedescription
127:             * The name of the attribute to set.
128:             * 
129:             * @jsptagref.databindable false
130:             * 
131:             * @jsptagref.attributesyntaxvalue <i>string_name</i>
132:             *
133:             * @netui:attribute required="true" rtexprvalue="true"
134:             * description="The name of the attribute to set."
135:             */
136:            public void setName(String name) {
137:                _name = name;
138:            }
139:
140:            /**
141:             * Set the value of the <code>Attribute</code>.  This attribute
142:             * may be assigned a read only expression.
143:             * @param value The value to use for the <code>Attribute</code>
144:             *  in the template.
145:             *
146:             * @jsptagref.attributedescription
147:             * Sets the value of the attribute.
148:             * 
149:             * @jsptagref.databindable Read Only
150:             * 
151:             * @jsptagref.attributesyntaxvalue <i>string_or_expression_value</i>
152:             *
153:             * @netui:attribute required="true" rtexprvalue="true"
154:             * description="Sets the value of the attribute."
155:             */
156:            public void setValue(String value) throws JspException {
157:                _value = value;
158:            }
159:
160:            /**
161:             * Tag Lifecycle method called when the tag is first seen.  This method
162:             * will add the <code>Attribute</code> value to a <code>HashMap</code>
163:             * stored in the request allowing the template to access the value.  If
164:             * there are errors, the error text will be placed into the attribute
165:             * value.  Nothing is written into the <code>ServletResponse</code>
166:             * @return EVAL_PAGE to continue processing the page.
167:             * @throws JspException on error
168:             */
169:            public int doStartTag() throws JspException {
170:                ServletRequest req = pageContext.getRequest();
171:                HashMap atts = (HashMap) req.getAttribute(TEMPLATE_ATTRIBUTES);
172:                if (atts == null) {
173:                    atts = new HashMap();
174:                    req.setAttribute(TEMPLATE_ATTRIBUTES, atts);
175:                }
176:                if (hasErrors()) {
177:                    String s = getErrorsReport();
178:                    atts.put(_name, s);
179:                    localRelease();
180:                    return EVAL_PAGE;
181:                }
182:
183:                atts.put(_name, _value);
184:                localRelease();
185:                return EVAL_PAGE;
186:            }
187:
188:            /**
189:             * Reset all of the fields of the tag.
190:             */
191:            protected void localRelease() {
192:                super.localRelease();
193:                _name = null;
194:                _value = null;
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.