Source Code Cross Referenced for BindTag.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » tags » 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 » J2EE » spring framework 2.0.6 » org.springframework.web.servlet.tags 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2007 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.web.servlet.tags;
018:
019:        import java.beans.PropertyEditor;
020:
021:        import javax.servlet.jsp.JspTagException;
022:        import javax.servlet.jsp.PageContext;
023:
024:        import org.springframework.validation.Errors;
025:        import org.springframework.web.servlet.support.BindStatus;
026:        import org.springframework.web.util.ExpressionEvaluationUtils;
027:
028:        /**
029:         * Bind tag, supporting evaluation of binding errors for a certain
030:         * bean or bean property. Exposes a "status" variable of type
031:         * {@link org.springframework.web.servlet.support.BindStatus},
032:         * to both Java expressions and JSP EL expressions.
033:         *
034:         * <p>Can be used to bind to any bean or bean property in the model.
035:         * The specified path determines whether the tag exposes the status of the
036:         * bean itself (showing object-level errors), a specific bean property
037:         * (showing field errors), or a matching set of bean properties
038:         * (showing all corresponding field errors).
039:         *
040:         * <p>The {@link org.springframework.validation.Errors} object that has
041:         * been bound using this tag is exposed to collaborating tags, as well
042:         * as the bean property that this errors object applies to. Nested tags
043:         * such as the {@link TransformTag} can access those exposed properties.
044:         *
045:         * @author Rod Johnson
046:         * @author Juergen Hoeller
047:         * @see #setPath
048:         */
049:        public class BindTag extends HtmlEscapingAwareTag {
050:
051:            /**
052:             * Name of the exposed variable within the scope of this tag: "status".
053:             */
054:            public static final String STATUS_VARIABLE_NAME = "status";
055:
056:            private String path;
057:
058:            private boolean ignoreNestedPath = false;
059:
060:            private BindStatus status;
061:
062:            private Object previousPageStatus;
063:
064:            private Object previousRequestStatus;
065:
066:            /**
067:             * Set the path that this tag should apply. Can be a bean (e.g. "person")
068:             * to get global errors, or a bean property (e.g. "person.name") to get
069:             * field errors (also supporting nested fields and "person.na*" mappings).
070:             * "person.*" will return all errors for the specified bean, both global
071:             * and field errors.
072:             * @see org.springframework.validation.Errors#getGlobalErrors
073:             * @see org.springframework.validation.Errors#getFieldErrors
074:             */
075:            public void setPath(String path) {
076:                this .path = path;
077:            }
078:
079:            /**
080:             * Return the path that this tag applies to.
081:             */
082:            public String getPath() {
083:                return this .path;
084:            }
085:
086:            /**
087:             * Set whether to ignore a nested path, if any.
088:             * Default is to not ignore.
089:             */
090:            public void setIgnoreNestedPath(boolean ignoreNestedPath) {
091:                this .ignoreNestedPath = ignoreNestedPath;
092:            }
093:
094:            /**
095:             * Return whether to ignore a nested path, if any.
096:             */
097:            public boolean isIgnoreNestedPath() {
098:                return this .ignoreNestedPath;
099:            }
100:
101:            protected final int doStartTagInternal() throws Exception {
102:                String resolvedPath = ExpressionEvaluationUtils.evaluateString(
103:                        "path", getPath(), pageContext);
104:
105:                if (!isIgnoreNestedPath()) {
106:                    String nestedPath = (String) pageContext.getAttribute(
107:                            NestedPathTag.NESTED_PATH_VARIABLE_NAME,
108:                            PageContext.REQUEST_SCOPE);
109:                    if (nestedPath != null) {
110:                        resolvedPath = nestedPath + resolvedPath;
111:                    }
112:                }
113:
114:                try {
115:                    this .status = new BindStatus(getRequestContext(),
116:                            resolvedPath, isHtmlEscape());
117:                } catch (IllegalStateException ex) {
118:                    throw new JspTagException(ex.getMessage());
119:                }
120:
121:                // Save previous status values, for re-exposure at the end of this tag.
122:                this .previousPageStatus = pageContext.getAttribute(
123:                        STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE);
124:                this .previousRequestStatus = pageContext.getAttribute(
125:                        STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
126:
127:                // Expose this tag's status object as PageContext attribute,
128:                // making it available for JSP EL.
129:                pageContext.removeAttribute(STATUS_VARIABLE_NAME,
130:                        PageContext.PAGE_SCOPE);
131:                pageContext.setAttribute(STATUS_VARIABLE_NAME, this .status,
132:                        PageContext.REQUEST_SCOPE);
133:
134:                return EVAL_BODY_INCLUDE;
135:            }
136:
137:            public int doEndTag() {
138:                // Reset previous status values.
139:                if (this .previousPageStatus != null) {
140:                    pageContext.setAttribute(STATUS_VARIABLE_NAME,
141:                            this .previousPageStatus, PageContext.PAGE_SCOPE);
142:                }
143:                if (this .previousRequestStatus != null) {
144:                    pageContext.setAttribute(STATUS_VARIABLE_NAME,
145:                            this .previousRequestStatus,
146:                            PageContext.REQUEST_SCOPE);
147:                } else {
148:                    pageContext.removeAttribute(STATUS_VARIABLE_NAME,
149:                            PageContext.REQUEST_SCOPE);
150:                }
151:                return EVAL_PAGE;
152:            }
153:
154:            /**
155:             * Retrieve the property that this tag is currently bound to,
156:             * or <code>null</code> if bound to an object rather than a specific property.
157:             * Intended for cooperating nesting tags.
158:             * @return the property that this tag is currently bound to,
159:             * or <code>null</code> if none
160:             */
161:            public final String getProperty() {
162:                return this .status.getExpression();
163:            }
164:
165:            /**
166:             * Retrieve the Errors instance that this tag is currently bound to.
167:             * Intended for cooperating nesting tags.
168:             * @return the current Errors instance, or <code>null</code> if none
169:             */
170:            public final Errors getErrors() {
171:                return this .status.getErrors();
172:            }
173:
174:            /**
175:             * Retrieve the PropertyEditor for the property that this tag is
176:             * currently bound to. Intended for cooperating nesting tags.
177:             * @return the current PropertyEditor, or <code>null</code> if none
178:             */
179:            public final PropertyEditor getEditor() {
180:                return this .status.getEditor();
181:            }
182:
183:            public void doFinally() {
184:                super.doFinally();
185:                this.status = null;
186:                this.previousPageStatus = null;
187:                this.previousRequestStatus = null;
188:            }
189:
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.