Source Code Cross Referenced for VelocityOnlyLayout.java in  » Web-Framework » TURBINE » org » apache » turbine » modules » layouts » 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 » TURBINE » org.apache.turbine.modules.layouts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.modules.layouts;
002:
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:
022:        import org.apache.commons.logging.Log;
023:        import org.apache.commons.logging.LogFactory;
024:
025:        import org.apache.ecs.ConcreteElement;
026:
027:        import org.apache.turbine.TurbineConstants;
028:        import org.apache.turbine.modules.Layout;
029:        import org.apache.turbine.modules.ScreenLoader;
030:        import org.apache.turbine.services.velocity.TurbineVelocity;
031:        import org.apache.turbine.util.RunData;
032:        import org.apache.turbine.util.template.TemplateNavigation;
033:
034:        import org.apache.velocity.context.Context;
035:
036:        /**
037:         * This Layout module allows Velocity templates to be used as layouts.
038:         * Since dynamic content is supposed to be primarily located in
039:         * screens and navigations there should be relatively few reasons to
040:         * subclass this Layout.
041:         *
042:         * To get the same functionality as with VelocityECSLayout, you can use two
043:         * supplied VelocityMacros, TurbineHtmlHead and TurbineHtmlBodyAttributes
044:         * in your templates. These are used to put HtmlPageAttributes into a page
045:         * before rendering.
046:         *
047:         * Use these macros should be used in the Layout template like this:
048:         *
049:         * ... set things like style sheets, scripts here.
050:         * <html>
051:         * #TurbineHtmlHead()
052:         * <body #TurbineHtmlBodyAttributes() >
053:         *  .... your body information
054:         * </body>
055:         * </html>
056:         *
057:         * As the layout template is rendered _after_ the screen template, you
058:         * can of course, add information to the $page tool in your screen template.
059:         * This will be added correctly to the <head>...</head> and
060:         * <body> tags.
061:         *
062:         * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
063:         * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
064:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
065:         * @version $Id: VelocityOnlyLayout.java 534527 2007-05-02 16:10:59Z tv $
066:         */
067:        public class VelocityOnlyLayout extends Layout {
068:            /** Logging */
069:            private static Log log = LogFactory
070:                    .getLog(VelocityOnlyLayout.class);
071:
072:            /** The prefix for lookup up layout pages */
073:            private String prefix = TurbineConstants.LAYOUT_PREFIX + "/";
074:
075:            /**
076:             * Build the layout.  Also sets the ContentType and Locale headers
077:             * of the HttpServletResponse object.
078:             *
079:             * @param data Turbine information.
080:             * @exception Exception a generic exception.
081:             */
082:            public void doBuild(RunData data) throws Exception {
083:                // Get the context needed by Velocity.
084:                Context context = TurbineVelocity.getContext(data);
085:
086:                String screenName = data.getScreen();
087:
088:                log.debug("Loading Screen " + screenName);
089:
090:                // First, generate the screen and put it in the context so
091:                // we can grab it the layout template.
092:                ConcreteElement results = ScreenLoader.getInstance().eval(data,
093:                        screenName);
094:
095:                String returnValue = (results == null) ? "" : results
096:                        .toString();
097:
098:                // variable for the screen in the layout template
099:                context.put(TurbineConstants.SCREEN_PLACEHOLDER, returnValue);
100:
101:                // variable to reference the navigation screen in the layout template
102:                context.put(TurbineConstants.NAVIGATION_PLACEHOLDER,
103:                        new TemplateNavigation(data));
104:
105:                // Grab the layout template set in the VelocityPage.
106:                // If null, then use the default layout template
107:                // (done by the TemplateInfo object)
108:                String templateName = data.getTemplateInfo()
109:                        .getLayoutTemplate();
110:
111:                // Set the locale and content type
112:                data.getResponse().setLocale(data.getLocale());
113:                data.getResponse().setContentType(data.getContentType());
114:
115:                log.debug("Now trying to render layout " + templateName);
116:
117:                // Finally, generate the layout template and send it to the browser
118:                data.getOut().print(
119:                        TurbineVelocity.handleRequest(context, prefix
120:                                + templateName));
121:            }
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.