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


001:        /*
002:         * Copyright 2002-2006 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.view.velocity;
018:
019:        import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
020:        import org.springframework.web.servlet.view.AbstractUrlBasedView;
021:
022:        /**
023:         * Convenience subclass of UrlBasedViewResolver that supports VelocityView
024:         * (that is Velocity templates) and custom subclasses of it.
025:         *
026:         * <p>The view class for all views generated by this resolver can be specified
027:         * via <code>setViewClass</code>. See UrlBasedViewResolver's javadoc for details.
028:         *
029:         * <p><b>Note:</b> When chaining ViewResolvers, a VelocityViewResolver always needs
030:         * to be last, as it will attempt to resolve any view name, no matter whether
031:         * the underlying resource actually exists.
032:         *
033:         * @author Juergen Hoeller
034:         * @since 13.12.2003
035:         * @see #setViewClass
036:         * @see #setPrefix
037:         * @see #setSuffix
038:         * @see #setRequestContextAttribute
039:         * @see #setExposeSpringMacroHelpers
040:         * @see #setVelocityFormatterAttribute
041:         * @see #setDateToolAttribute
042:         * @see #setNumberToolAttribute
043:         * @see VelocityView
044:         */
045:        public class VelocityViewResolver extends AbstractTemplateViewResolver {
046:
047:            private String velocityFormatterAttribute;
048:
049:            private String dateToolAttribute;
050:
051:            private String numberToolAttribute;
052:
053:            private String toolboxConfigLocation;
054:
055:            /**
056:             * Sets default viewClass to <code>requiredViewClass</code>.
057:             * @see #setViewClass
058:             * @see #requiredViewClass
059:             */
060:            public VelocityViewResolver() {
061:                setViewClass(requiredViewClass());
062:            }
063:
064:            /**
065:             * Requires VelocityView.
066:             * @see VelocityView
067:             */
068:            protected Class requiredViewClass() {
069:                return VelocityView.class;
070:            }
071:
072:            /**
073:             * Set the name of the VelocityFormatter helper object to expose in the
074:             * Velocity context of this view, or <code>null</code> if not needed.
075:             * VelocityFormatter is part of the standard Velocity distribution.
076:             * @see org.apache.velocity.app.tools.VelocityFormatter
077:             * @see VelocityView#setVelocityFormatterAttribute
078:             */
079:            public void setVelocityFormatterAttribute(
080:                    String velocityFormatterAttribute) {
081:                this .velocityFormatterAttribute = velocityFormatterAttribute;
082:            }
083:
084:            /**
085:             * Set the name of the DateTool helper object to expose in the Velocity context
086:             * of this view, or <code>null</code> if not needed. DateTool is part of Velocity Tools 1.0.
087:             * @see org.apache.velocity.tools.generic.DateTool
088:             * @see VelocityView#setDateToolAttribute
089:             */
090:            public void setDateToolAttribute(String dateToolAttribute) {
091:                this .dateToolAttribute = dateToolAttribute;
092:            }
093:
094:            /**
095:             * Set the name of the NumberTool helper object to expose in the Velocity context
096:             * of this view, or <code>null</code> if not needed. NumberTool is part of Velocity Tools 1.1.
097:             * @see org.apache.velocity.tools.generic.NumberTool
098:             * @see VelocityView#setNumberToolAttribute
099:             */
100:            public void setNumberToolAttribute(String numberToolAttribute) {
101:                this .numberToolAttribute = numberToolAttribute;
102:            }
103:
104:            /**
105:             * Set a Velocity Toolbox config location, for example "/WEB-INF/toolbox.xml",
106:             * to automatically load a Velocity Tools toolbox definition file and expose
107:             * all defined tools in the specified scopes. If no config location is
108:             * specified, no toolbox will be loaded and exposed.
109:             * <p>The specfied location string needs to refer to a ServletContext
110:             * resource, as expected by ServletToolboxManager which is part of
111:             * the view package of Velocity Tools.
112:             * <p><b>Note:</b> Specifying a toolbox config location will lead to
113:             * VelocityToolboxView instances being created.
114:             * @see org.apache.velocity.tools.view.servlet.ServletToolboxManager#getInstance
115:             * @see VelocityToolboxView#setToolboxConfigLocation
116:             */
117:            public void setToolboxConfigLocation(String toolboxConfigLocation) {
118:                this .toolboxConfigLocation = toolboxConfigLocation;
119:            }
120:
121:            protected void initApplicationContext() {
122:                super .initApplicationContext();
123:
124:                if (this .toolboxConfigLocation != null) {
125:                    if (VelocityView.class.equals(getViewClass())) {
126:                        logger
127:                                .info("Using VelocityToolboxView instead of default VelocityView "
128:                                        + "due to specified toolboxConfigLocation");
129:                        setViewClass(VelocityToolboxView.class);
130:                    } else if (!VelocityToolboxView.class
131:                            .isAssignableFrom(getViewClass())) {
132:                        throw new IllegalArgumentException(
133:                                "Given view class ["
134:                                        + getViewClass().getName()
135:                                        + "] is not of type ["
136:                                        + VelocityToolboxView.class.getName()
137:                                        + "], which it needs to be in case of a specified toolboxConfigLocation");
138:                    }
139:                }
140:            }
141:
142:            protected AbstractUrlBasedView buildView(String viewName)
143:                    throws Exception {
144:                VelocityView view = (VelocityView) super .buildView(viewName);
145:                view
146:                        .setVelocityFormatterAttribute(this .velocityFormatterAttribute);
147:                view.setDateToolAttribute(this .dateToolAttribute);
148:                view.setNumberToolAttribute(this .numberToolAttribute);
149:                if (this .toolboxConfigLocation != null) {
150:                    ((VelocityToolboxView) view)
151:                            .setToolboxConfigLocation(this.toolboxConfigLocation);
152:                }
153:                return view;
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.