Source Code Cross Referenced for GetData.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » databinding » script » 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.databinding.script 
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.databinding.script;
020:
021:        import javax.servlet.jsp.JspException;
022:
023:        import org.apache.beehive.netui.tags.AbstractClassicTag;
024:        import org.apache.beehive.netui.util.logging.Logger;
025:
026:        /**
027:         * <p>
028:         * This tag evaluates an expression and places the result in the
029:         * {@link javax.servlet.jsp.PageContext} object, where the data is available to the JSP EL and JSP scriptlet.
030:         * This tag can be used to extract data from forms, Controller files, and any data binding context and
031:         * make it available to scriptlets.
032:         * </p>
033:         * <p>
034:         * In the following example, the getData tag gets the value of a property in the page flow and
035:         * makes it available to the JSP via the JSP EL implicit object <code>${pageScope}</code>.
036:         * <pre>
037:         *     &lt;netui-data:getData resultId="myData" value="${pageFlow.myData}"/>
038:         * </pre>
039:         * <p>
040:         * The following scriptlet extracts the data from the <code>PageContext</code> object and writes it to
041:         * the rendered HTML: <br/>
042:         * <pre>
043:         *     ${pageScope.myData}
044:         * </pre>
045:         * </p>
046:         * In this first example, the &lt;netui-data:getData> tag loads data into the {@link javax.servlet.jsp.PageContext}'s
047:         * attribute map.  It can then be accessed using the {@link javax.servlet.jsp.PageContext#getAttribute(String)} method.
048:         * <pre>
049:         *     &lt;netui:form action="lastNameAction" focus="lastname"&gt;
050:         *         ...
051:         *         &lt;netui-data:getData resultId="first" value="${actionForm.firstname}"/&gt;
052:         *         ...
053:         *         &lt;%
054:         *             String firstName = (String)pageContext.getAttribute("first");
055:         *             System.out.println("First Name = " + firstName);
056:         *             ...
057:         *         %&gt;
058:         *         ...
059:         *     &lt;/netui:form&gt;</pre>
060:         * <p/>
061:         * <p>
062:         * This example shows how to use &lt;netui-data:getData&gt; and the <code>PageContext</code> inside of other
063:         * containers, in this case a &lt;netui-data:repeater> tag. The &lt;netui-data:getData> below extracts each
064:         * element as the &lt;netui-data:repeater> iterates over the data set and writes it to the Java console:
065:         * <br/>
066:         * <pre>    &lt;netui-data:repeater dataSource="pageFlow.strArr"&gt;
067:         *         ...
068:         *         &lt;netui-data:repeaterItem&gt;
069:         *             &lt;netui:span value="${container.item}" /&gt;
070:         *             &lt;netui-data:getData resultId="item" value="${container.item}"/&gt;
071:         *             &lt;%
072:         *                 String currentItem = (String) pageContext.getAttribute("item");
073:         *                 System.out.println(currentItem);
074:         *                 ...
075:         *             %&gt;
076:         *          &lt;/netui-data:repeaterItem&gt;
077:         *          ...
078:         *      &lt;/netui-data:repeater&gt;
079:         * </pre>
080:         * </p>
081:         *
082:         * @jsptagref.tagdescription
083:         * <p>
084:         * This tag evaluates an expression and places the result in the
085:         * {@link javax.servlet.jsp.PageContext} object, where the data is available to the JSP EL and JSP scriptlet.
086:         * This tag can be used to extract data from forms, Controller files, and any data binding context and
087:         * make it available to scriptlets.
088:         * </p>
089:         * <p>
090:         * In the following example, the getData tag gets the value of a property in the page flow and
091:         * makes it available to the JSP via the JSP EL implicit object <code>${pageScope}</code>.
092:         * <pre>
093:         *     &lt;netui-data:getData resultId="myData" value="${pageFlow.myData}"/>
094:         * </pre>
095:         * <p>
096:         * The following scriptlet extracts the data from the <code>PageContext</code> object and writes it to
097:         * the rendered HTML: <br/>
098:         * <pre>
099:         *     ${pageScope.myData}
100:         * </pre>
101:         *
102:         * @example
103:         * In this first example, the &lt;netui-data:getData> tag loads data into the {@link javax.servlet.jsp.PageContext}'s
104:         * attribute map.  It can then be accessed using the {@link javax.servlet.jsp.PageContext#getAttribute(String)} method.
105:         * <pre>
106:         *     &lt;netui:form action="lastNameAction" focus="lastname"&gt;
107:         *         ...
108:         *         &lt;netui-data:getData resultId="first" value="${actionForm.firstname}"/&gt;
109:         *         ...
110:         *         &lt;%
111:         *             String firstName = (String)pageContext.getAttribute("first");
112:         *             System.out.println("First Name = " + firstName);
113:         *             ...
114:         *         %&gt;
115:         *         ...
116:         *     &lt;/netui:form&gt;</pre>
117:         * <p/>
118:         * <p>
119:         * This example shows how to use &lt;netui-data:getData&gt; and the <code>PageContext</code> inside of other
120:         * containers, in this case a &lt;netui-data:repeater> tag. The &lt;netui-data:getData> below extracts each
121:         * element as the &lt;netui-data:repeater> iterates over the data set and writes it to the Java console:
122:         * <br/>
123:         * <pre>    &lt;netui-data:repeater dataSource="pageFlow.strArr"&gt;
124:         *         ...
125:         *         &lt;netui-data:repeaterItem&gt;
126:         *             &lt;netui:span value="${container.item}" /&gt;
127:         *             &lt;netui-data:getData resultId="item" value="${container.item}"/&gt;
128:         *             &lt;%
129:         *                 String currentItem = (String) pageContext.getAttribute("item");
130:         *                 System.out.println(currentItem);
131:         *                 ...
132:         *             %&gt;
133:         *          &lt;/netui-data:repeaterItem&gt;
134:         *          ...
135:         *      &lt;/netui-data:repeater&gt;
136:         * </pre>
137:         * </p>
138:         * @netui:tag name="getData"
139:         *            description="Evaluates an expression and places the result in the JSP's PageContext. Can be used to extract objects from forms, page flows, and other objects that can be databound.  You can then write a scriplet to access the data by using the getAttribute method of javax.servlet.jsp.PageContext."
140:         * @deprecated The JSP expression language should be used instead. 
141:         */
142:        public class GetData extends AbstractClassicTag {
143:
144:            private static final Logger LOGGER = Logger
145:                    .getInstance(GetData.class);
146:
147:            private Object _value = null;
148:            private String _resultId = null;
149:
150:            /**
151:             * Get the name of this tag.  This is used to identify the type of this tag
152:             * for reporting tag errors.
153:             *
154:             * @return a constant String representing the name of this tag.
155:             */
156:            public String getTagName() {
157:                return "GetData";
158:            }
159:
160:            /**
161:             * The data binding expression to evaluate. The result will be stored in the {@link javax.servlet.jsp.PageContext}
162:             * object as specified in the <code>resultId</code> attribute.
163:             *
164:             * @param value the expression to evaluate
165:             * @jsptagref.attributedescription
166:             * The data binding expression to evaluate. The result will be stored in the {@link javax.servlet.jsp.PageContext}
167:             * object as specified in the <code>resultId</code> attribute.
168:             * @jsptagref.attributesyntaxvalue <i>expression_value</i>
169:             * @netui:attribute required="true" rtexprvalue="true"
170:             */
171:            public void setValue(Object value) {
172:                _value = value;
173:            }
174:
175:            /**
176:             * Set the String attribute name under which the result of evaluating an expression will be stored in
177:             * the {@link javax.servlet.jsp.PageContext}..
178:             *
179:             * @param resultId the String key
180:             * @jsptagref.attributedescription
181:             * Specifies the property of the PageContext object where the data will be stored.
182:             * @jsptagref.attributesyntaxvalue <i>string_resultId</i>
183:             * @netui:attribute required="true"
184:             */
185:            public void setResultId(String resultId) {
186:                _resultId = resultId;
187:            }
188:
189:            /**
190:             * Start the tag evaluation.  This tag ignores its body content.
191:             *
192:             * @return {@link #SKIP_BODY}
193:             */
194:            public int doStartTag() {
195:                return SKIP_BODY;
196:            }
197:
198:            /**
199:             * Evaluate the expression at the <code>value</code> attribute and store the result in the
200:             * {@link javax.servlet.jsp.PageContext} under the attribute key specified in {@link #setResultId(String)}.
201:             * If an existing key in the PageContext's attribute map exists, a warning will be written to the log file.
202:             * If errors occur during expression evaluation, they will be reported in the JSP page.  If the value
203:             * returned by the expression is null, an attribute named <code>resultId</code> will be removed from
204:             * the PageContext's attribute map.
205:             *
206:             * @return {@link #EVAL_PAGE}
207:             */
208:            public int doEndTag() throws JspException {
209:                if (_value != null) {
210:                    if (LOGGER.isInfoEnabled()
211:                            && pageContext.getAttribute(_resultId) != null)
212:                        LOGGER
213:                                .info("Overwriting a value in PageContext attribute map with key \""
214:                                        + _resultId
215:                                        + "\" and object of type \""
216:                                        + _value.getClass().getName());
217:
218:                    pageContext.setAttribute(_resultId, _value);
219:                } else {
220:                    if (LOGGER.isInfoEnabled())
221:                        LOGGER
222:                                .info("Removing a value from the PageContext attribute map with key \""
223:                                        + _resultId
224:                                        + "\".  The object returned by the expression is null.");
225:
226:                    pageContext.removeAttribute(_resultId);
227:                }
228:
229:                localRelease();
230:                return EVAL_PAGE;
231:            }
232:
233:            /**
234:             * Reset all of the fields of this tag.
235:             */
236:            protected void localRelease() {
237:                super.localRelease();
238:                _resultId = null;
239:                _value = null;
240:            }
241:        }
w_w_w__.___j_a___v___a2___s_.__c_o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.