Source Code Cross Referenced for DeclarePageInput.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » databinding » pageinput » 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.pageinput 
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.pageinput;
020:
021:        import java.util.Map;
022:        import javax.servlet.jsp.JspException;
023:        import javax.servlet.jsp.PageContext;
024:        import javax.servlet.http.HttpServletRequest;
025:
026:        import org.apache.beehive.netui.pageflow.internal.InternalUtils;
027:        import org.apache.beehive.netui.util.Bundle;
028:        import org.apache.beehive.netui.util.logging.Logger;
029:        import org.apache.beehive.netui.tags.AbstractSimpleTag;
030:
031:        /**
032:         * <p>
033:         * The DeclarePageInput tag is used to declare variables that are passed as outputs of Page Flow actions to a
034:         * JSP.  This allows pages to declare a data contract that invoking actions must satisfy in order to
035:         * successfully render a page; in essence, this is a simple method signature for the JSP.
036:         * </p>
037:         * <p>
038:         * Page inputs are added to a Page Flow's {@link org.apache.beehive.netui.pageflow.Forward} class via the
039:         * {@link org.apache.beehive.netui.pageflow.Forward#addActionOutput(String, Object)} method.  From the page's
040:         * perspective, the action outputs are known as <i>page inputs</i> and are available via the JSP EL
041:         * implicit object <code>pageInput</code> using the name given them on the
042:         * {@link org.apache.beehive.netui.pageflow.Forward} and set on this tag via {@link #setName(String)}.
043:         * </p>
044:         * <p>
045:         * A page input can be declared to be required; if required, the page input must be available in
046:         * the map of action outputs passed to the page.
047:         * </p>
048:         * <p>
049:         * For example, to add an actiout output called <code>profile</code> to a {@link org.apache.beehive.netui.pageflow.Forward}
050:         * an action would contain code like:<br/>
051:         * <pre>
052:         *     forward.addActionOutput("profile", yourProfile);
053:         * </pre>
054:         * In order to declare this as a page input in a JSP, the page would contain a tag as:
055:         * <pre>
056:         *     &lt;netui-data:declarePageInput name="profile" type="org.someprofile.ProfileBean"/>
057:         * </pre>
058:         * and the <code>profile</code> object could be referenced in the JSP as:
059:         * <pre>
060:         *     ${pageInput.profile}
061:         * </pre>
062:         * </p>
063:         *
064:         * @jsptagref.tagdescription
065:         * <p>
066:         * The DeclarePageInput tag is used to declare variables that are passed as outputs of Page Flow actions to a
067:         * JSP.  This allows pages to declare a data contract that invoking actions must satisfy in order to
068:         * successfully render a page; in essence, this is a simple method signature for the JSP.
069:         * </p>
070:         * <p>
071:         * Page inputs are added to a Page Flow's {@link org.apache.beehive.netui.pageflow.Forward} class via the
072:         * {@link org.apache.beehive.netui.pageflow.Forward#addActionOutput(String, Object)} method.  From the page's
073:         * perspective, the action outputs are known as <i>page inputs</i> and are available via the JSP EL
074:         * implicit object <code>pageInput</code> using the name given them on the
075:         * {@link org.apache.beehive.netui.pageflow.Forward} and set on this tag via {@link #setName(String)}.
076:         * </p>
077:         * <p>
078:         * A page input can be declared to be required; if required, the page input must be available in
079:         * the map of action outputs passed to the page.
080:         * </p>
081:         * <p>
082:         * For example, to add an actiout output called <code>profile</code> to a {@link org.apache.beehive.netui.pageflow.Forward}
083:         * an action would contain code like:<br/>
084:         * <pre>
085:         *     forward.addActionOutput("profile", yourProfile);
086:         * </pre>
087:         * In order to declare this as a page input in a JSP, the page would contain a tag as:
088:         * <pre>
089:         *     &lt;netui-data:declarePageInput name="profile" type="org.someprofile.ProfileBean"/>
090:         * </pre>
091:         * and the <code>profile</code> object could be referenced in the JSP as:
092:         * <pre>
093:         *     ${pageInput.profile}
094:         * </pre>
095:         * </p>
096:         *
097:         * @netui:tag name="declarePageInput" body-content="scriptless"
098:         *            description="Use this tag to declare a page input variable that is available in the pageInput databinding context."
099:         */
100:        public class DeclarePageInput extends AbstractSimpleTag {
101:
102:            private static final Logger LOGGER = Logger
103:                    .getInstance(DeclarePageInput.class);
104:            private static final String EMPTY_STRING = "";
105:
106:            private String _type = null;
107:            private String _name = null;
108:            private boolean _required = true;
109:
110:            /**
111:             * Get the name of this tag.  This is used to identify the type of this tag
112:             * for reporting tag errors.
113:             *
114:             * @return a constant String representing the name of this tag.
115:             */
116:            public String getTagName() {
117:                return "DeclarePageInput";
118:            }
119:
120:            /**
121:             * Set the name of a variable that can be referecned using the page
122:             * input data binding context.
123:             *
124:             * @param name the name of the variable
125:             * @jsptagref.attributedescription The name of the variable to reference.
126:             * @jsptagref.attributesyntaxvalue <i>string_name</i>
127:             * @netui:attribute required="true"
128:             */
129:            public void setName(String name) {
130:                _name = name;
131:            }
132:
133:            /**
134:             * Set a flag that declares whether this page intput is required or optiona.  If a Page Input is required,
135:             * the tag will report an error if the page input key does not appear in the set of page inputs for a page.
136:             *
137:             * @param required whether to require the page input for the page
138:             * @jsptagref.attributedescription
139:             * Set a flag that declares whether this page intput is required or optiona.  If a Page Input is required,
140:             * the tag will report an error if the page input key does not appear in the set of page inputs for a page.
141:             * @jsptagref.attributesyntaxvalue <i>string_name</i>
142:             * @netui:attribute required="false"
143:             */
144:            public void setRequired(boolean required) {
145:                _required = required;
146:            }
147:
148:            /**
149:             * Set the String classname variable that represents the expected type of the page input.
150:             *
151:             * @param type the type of the variable that is referenced
152:             * @jsptagref.attributedescription
153:             * Set the String classname variable that represents the expected type of the page input.
154:             * @jsptagref.attributesyntaxvalue <i>string_type</i>
155:             * @netui:attribute required="true"
156:             */
157:            public void setType(String type) {
158:                _type = type;
159:            }
160:
161:            /**
162:             *
163:             */
164:            public void doTag() throws JspException {
165:
166:                LOGGER.debug("Added a page input named \"" + _name
167:                        + "\" of type \"" + _type + "\"");
168:
169:                if (_name.equals(EMPTY_STRING)) {
170:                    String msg = Bundle
171:                            .getErrorString("Tags_DeclarePageInput_EmptyName");
172:                    registerTagError(msg, null);
173:                }
174:
175:                if (_type.equals(EMPTY_STRING)) {
176:                    String msg = Bundle
177:                            .getErrorString("Tags_DeclarePageInput_EmptyType");
178:                    registerTagError(msg, null);
179:                }
180:
181:                if (_required) {
182:                    assert getJspContext() instanceof  PageContext;
183:                    assert ((PageContext) getJspContext()).getRequest() instanceof  HttpServletRequest;
184:
185:                    HttpServletRequest request = (HttpServletRequest) ((PageContext) getJspContext())
186:                            .getRequest();
187:                    Map actionOutputMap = InternalUtils
188:                            .getPageInputMap(request);
189:                    if (actionOutputMap == null
190:                            || !actionOutputMap.containsKey(_name)) {
191:                        String msg = Bundle.getErrorString(
192:                                "Tags_DeclarePageInput_Required",
193:                                new Object[] { _name });
194:                        registerTagError(msg, null);
195:                    }
196:                }
197:
198:                if (hasErrors())
199:                    reportErrors();
200:            }
201:        }
w_w_w_.___j_a___v__a__2__s._co__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.