Source Code Cross Referenced for DefineTag.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » taglib » bean » 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 » Web Framework » struts 1.3.8 » org.apache.struts.taglib.bean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: DefineTag.java 471754 2006-11-06 14:55:09Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:        package org.apache.struts.taglib.bean;
022:
023:        import org.apache.commons.logging.Log;
024:        import org.apache.commons.logging.LogFactory;
025:        import org.apache.struts.taglib.TagUtils;
026:        import org.apache.struts.util.MessageResources;
027:
028:        import javax.servlet.jsp.JspException;
029:        import javax.servlet.jsp.PageContext;
030:        import javax.servlet.jsp.tagext.BodyTagSupport;
031:
032:        /**
033:         * Define a scripting variable based on the value(s) of the specified bean
034:         * property.
035:         *
036:         * @version $Rev: 471754 $ $Date: 2005-06-15 12:16:32 -0400 (Wed, 15 Jun 2005)
037:         *          $
038:         */
039:        public class DefineTag extends BodyTagSupport {
040:            /**
041:             * Commons logging instance.
042:             */
043:            private static final Log log = LogFactory.getLog(DefineTag.class);
044:
045:            // ---------------------------------------------------- Protected variables
046:
047:            /**
048:             * The message resources for this package.
049:             */
050:            protected static MessageResources messages = MessageResources
051:                    .getMessageResources("org.apache.struts.taglib.bean.LocalStrings");
052:
053:            /**
054:             * The body content of this tag (if any).
055:             */
056:            protected String body = null;
057:
058:            // ------------------------------------------------------------- Properties
059:
060:            /**
061:             * The name of the scripting variable that will be exposed as a page scope
062:             * attribute.
063:             */
064:            protected String id = null;
065:
066:            /**
067:             * The name of the bean owning the property to be exposed.
068:             */
069:            protected String name = null;
070:
071:            /**
072:             * The name of the property to be retrieved.
073:             */
074:            protected String property = null;
075:
076:            /**
077:             * The scope within which to search for the specified bean.
078:             */
079:            protected String scope = null;
080:
081:            /**
082:             * The scope within which the newly defined bean will be creatd.
083:             */
084:            protected String toScope = null;
085:
086:            /**
087:             * The fully qualified Java class name of the value to be exposed.
088:             */
089:            protected String type = null;
090:
091:            /**
092:             * The (String) value to which the defined bean will be set.
093:             */
094:            protected String value = null;
095:
096:            public String getId() {
097:                return (this .id);
098:            }
099:
100:            public void setId(String id) {
101:                this .id = id;
102:            }
103:
104:            public String getName() {
105:                return (this .name);
106:            }
107:
108:            public void setName(String name) {
109:                this .name = name;
110:            }
111:
112:            public String getProperty() {
113:                return (this .property);
114:            }
115:
116:            public void setProperty(String property) {
117:                this .property = property;
118:            }
119:
120:            public String getScope() {
121:                return (this .scope);
122:            }
123:
124:            public void setScope(String scope) {
125:                this .scope = scope;
126:            }
127:
128:            public String getToScope() {
129:                return (this .toScope);
130:            }
131:
132:            public void setToScope(String toScope) {
133:                this .toScope = toScope;
134:            }
135:
136:            public String getType() {
137:                return (this .type);
138:            }
139:
140:            public void setType(String type) {
141:                this .type = type;
142:            }
143:
144:            public String getValue() {
145:                return (this .value);
146:            }
147:
148:            public void setValue(String value) {
149:                this .value = value;
150:            }
151:
152:            // --------------------------------------------------------- Public Methods
153:
154:            /**
155:             * Check if we need to evaluate the body of the tag
156:             *
157:             * @throws JspException if a JSP exception has occurred
158:             */
159:            public int doStartTag() throws JspException {
160:                return (EVAL_BODY_TAG);
161:            }
162:
163:            /**
164:             * Save the body content of this tag (if any), or throw a JspException if
165:             * the value was already defined.
166:             *
167:             * @throws JspException if value was defined by an attribute
168:             */
169:            public int doAfterBody() throws JspException {
170:                if (bodyContent != null) {
171:                    body = bodyContent.getString();
172:
173:                    if (body != null) {
174:                        body = body.trim();
175:                    }
176:
177:                    if (body.length() < 1) {
178:                        body = null;
179:                    }
180:                }
181:
182:                return (SKIP_BODY);
183:            }
184:
185:            /**
186:             * Retrieve the required property and expose it as a scripting variable.
187:             *
188:             * @throws JspException if a JSP exception has occurred
189:             */
190:            public int doEndTag() throws JspException {
191:                // Enforce restriction on ways to declare the new value
192:                int n = 0;
193:
194:                if (this .body != null) {
195:                    n++;
196:                }
197:
198:                if (this .name != null) {
199:                    n++;
200:                }
201:
202:                if (this .value != null) {
203:                    n++;
204:                }
205:
206:                if (n > 1) {
207:                    JspException e = new JspException(messages.getMessage(
208:                            "define.value", id));
209:
210:                    TagUtils.getInstance().saveException(pageContext, e);
211:                    throw e;
212:                }
213:
214:                // Retrieve the required property value
215:                Object value = this .value;
216:
217:                if ((value == null) && (name != null)) {
218:                    value = TagUtils.getInstance().lookup(pageContext, name,
219:                            property, scope);
220:                }
221:
222:                if ((value == null) && (body != null)) {
223:                    value = body;
224:                }
225:
226:                if (value == null) {
227:                    JspException e = new JspException(messages.getMessage(
228:                            "define.null", id));
229:
230:                    TagUtils.getInstance().saveException(pageContext, e);
231:                    throw e;
232:                }
233:
234:                // Expose this value as a scripting variable
235:                int inScope = PageContext.PAGE_SCOPE;
236:
237:                try {
238:                    if (toScope != null) {
239:                        inScope = TagUtils.getInstance().getScope(toScope);
240:                    }
241:                } catch (JspException e) {
242:                    log
243:                            .warn(
244:                                    "toScope was invalid name so we default to PAGE_SCOPE",
245:                                    e);
246:                }
247:
248:                pageContext.setAttribute(id, value, inScope);
249:
250:                // Continue processing this page
251:                return (EVAL_PAGE);
252:            }
253:
254:            /**
255:             * Release all allocated resources.
256:             */
257:            public void release() {
258:                super .release();
259:                body = null;
260:                id = null;
261:                name = null;
262:                property = null;
263:                scope = null;
264:                toScope = "page";
265:                type = null;
266:                value = null;
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.