Java Doc for TurbineTemplateService.java in  » Web-Framework » TURBINE » org » apache » turbine » services » template » 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.services.template 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.turbine.services.TurbineBaseService
   org.apache.turbine.services.template.TurbineTemplateService

TurbineTemplateService
public class TurbineTemplateService extends TurbineBaseService implements TemplateService(Code)
This service provides a method for mapping templates to their appropriate Screens or Navigations. It also allows templates to define a layout/navigations/screen modularization within the template structure. It also performs caching if turned on in the properties file. This service is not bound to a specific templating engine but we will use the Velocity templating engine for the examples. It is available by using the VelocityService. This assumes the following properties in the Turbine configuration:
 # Register the VelocityService for the "vm" extension.
 services.VelocityService.template.extension=vm
 # Default Java class for rendering a Page in this service
 # (must be found on the class path (org.apache.turbine.modules.page.VelocityPage))
 services.VelocityService.default.page = VelocityPage
 # Default Java class for rendering a Screen in this service
 # (must be found on the class path (org.apache.turbine.modules.screen.VelocityScreen))
 services.VelocityService.default.screen=VelocityScreen
 # Default Java class for rendering a Layout in this service
 # (must be found on the class path (org.apache.turbine.modules.layout.VelocityOnlyLayout))
 services.VelocityService.default.layout = VelocityOnlyLayout
 # Default Java class for rendering a Navigation in this service
 # (must be found on the class path (org.apache.turbine.modules.navigation.VelocityNavigation))
 services.VelocityService.default.navigation=VelocityNavigation
 # Default Template Name to be used as Layout. If nothing else is
 # found, return this as the default name for a layout
 services.VelocityService.default.layout.template = Default.vm
 
If you want to render a template, a search path is used to find a Java class which might provide information for the context of this template. If you request e.g. the template screen about,directions,Driving.vm then the following class names are searched (on the module search path): 1. about.directions.Driving <- direct matching the template to the class name 2. about.directions.Default <- matching the package, class name is Default 3. about.Default <- stepping up in the package hierarchy, looking for Default 4. Default <- Class called "Default" without package 5. VelocityScreen <- The class configured by the Service (VelocityService) to And if you have the following module packages configured: module.packages = org.apache.turbine.modules, com.mycorp.modules then the class loader will look for org.apache.turbine.modules.screens.about.directions.Driving com.mycorp.modules.screens.about.directions.Driving org.apache.turbine.modules.screens.about.directions.Default com.mycorp.modules.screens.about.directions.Default org.apache.turbine.modules.screens.about.Default com.mycorp.modules.screens.about.Default org.apache.turbine.modules.screens.Default com.mycorp.modules.screens.Default org.apache.turbine.modules.screens.VelocityScreen com.mycorp.modules.screens.VelocityScreen Most of the times, you don't have any backing Java class for a template screen, so the first match will be org.apache.turbine.modules.screens.VelocityScreen which then renders your screen. Please note, that your Screen Template (Driving.vm) must exist! If it does not exist, the Template Service will report an error. Once the screen is found, the template service will look for the Layout and Navigation templates of your Screen. Here, the template service looks for matching template names! Consider our example: about,directions,Driving.vm (Screen Name) Now the template service will look for the following Navigation and Layout templates: 1. about,directions,Driving.vm <- exact match 2. about,directions,Default.vm <- package match, Default name 3. about,Default.vm <- stepping up in the hierarchy 4. Default.vm <- The name configured as default.layout.template in the Velocity service. And now Hennings' two golden rules for using templates: Many examples and docs from older Turbine code show template pathes with a slashes. Repeat after me: "TEMPLATE NAMES NEVER CONTAIN SLASHES!" Many examples and docs from older Turbine code show templates that start with "/". This is not only a violation of the rule above but actively breaks things like loading templates from a jar with the velocity jar loader. Repeat after me: "TEMPLATE NAMES ARE NOT PATHES. THEY'RE NOT ABSOLUTE AND HAVE NO LEADING /". If you now wonder how a template name is mapped to a file name: This is scope of the templating engine. Velocity e.g. has this wonderful option to load templates from jar archives. There is no single file but you tell velocity "get about,directions,Driving.vm" and it returns the rendered template. This is not the job of the Templating Service but of the Template rendering services like VelocityService.
author:
   John D. McNally
author:
   Dave Bryson
author:
   Jason van Zyl
author:
   Daniel Rall
author:
   Ilkka Priha
author:
   Henning P. Schmiedehausen
version:
   $Id: TurbineTemplateService.java 534527 2007-05-02 16:10:59Z tv $


Field Summary
final public static  intLAYOUT_KEY
    
final public static  StringLAYOUT_NAME
    
final public static  intLAYOUT_TEMPLATE_KEY
    
final public static  StringLAYOUT_TEMPLATE_NAME
    
final public static  intNAVIGATION_KEY
    
final public static  StringNAVIGATION_NAME
    
final public static  intNAVIGATION_TEMPLATE_KEY
    
final public static  StringNAVIGATION_TEMPLATE_NAME
    
final protected static  StringNO_FILE_EXT
     The default file extension used as a registry key when a template's file extension cannot be determined.
final public static  intPAGE_KEY
    
final public static  StringPAGE_NAME
    
final public static  intSCREEN_KEY
    
final public static  StringSCREEN_NAME
    
final public static  intSCREEN_TEMPLATE_KEY
    
final public static  StringSCREEN_TEMPLATE_NAME
    
final public static  intTEMPLATE_TYPES
    

Constructor Summary
public  TurbineTemplateService()
    

Method Summary
public  StringgetDefaultExtension()
     Get the default template name extension specified in the template service properties.
public  StringgetDefaultLayout()
     Get the default layout module name of the template engine service corresponding to the default template name extension.
public  StringgetDefaultLayoutName(String template)
     Get the default layout module name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name.
public  StringgetDefaultLayoutName(RunData data)
     Find the default layout module name for the given request.
Parameters:
  data - The encapsulation of the request to retrieve thedefault layout for.
public  StringgetDefaultLayoutTemplate()
     Get the default layout template name of the template engine service corresponding to the default template name extension.
public  StringgetDefaultLayoutTemplateName(String template)
     Get the default layout template name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name.
public  StringgetDefaultNavigation()
     Get the default navigation module name of the template engine service corresponding to the default template name extension.
public  StringgetDefaultNavigationName(String template)
     Get the default navigation module name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name.
public  StringgetDefaultPage()
     Get the default page module name of the template engine service corresponding to the default template name extension.
public  StringgetDefaultPageName(String template)
     Get the default page module name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name.
public  StringgetDefaultPageName(RunData data)
     Find the default page module name for the given request.
Parameters:
  data - The encapsulation of the request to retrieve thedefault page for.
public  StringgetDefaultScreen()
     Get the default screen module name of the template engine service corresponding to the default template name extension.
public  StringgetDefaultScreenName(String template)
     Get the default screen module name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name.
public  StringgetDefaultTemplate()
     Returns the Default Template Name with the Default Extension.
public  StringgetExtension(String template)
    
public  StringgetLayoutName(String template)
     Locate and return the name of the layout module to be used with the named layout template.
Parameters:
  template - The layout template name.
public  StringgetLayoutTemplateName(String template)
     Locate and return the name of the layout template corresponding to the given screen template name parameter.
Parameters:
  template - The template name parameter.
public  StringgetNavigationName(String template)
     Locate and return the name of the navigation module to be used with the named navigation template.
Parameters:
  template - The navigation template name.
public  StringgetNavigationTemplateName(String template)
     Locate and return the name of the navigation template corresponding to the given template name parameter.
public  StringgetScreenName(String template)
     Locate and return the name of the screen module to be used with the named screen template.
Parameters:
  template - The screen template name.
public  StringgetScreenTemplateName(String template)
     Locate and return the name of the screen template corresponding to the given template name parameter.
public  TemplateEngineServicegetTemplateEngineService(String template)
     The org.apache.turbine.services.template.TemplateEngineService associated with the specified template's file extension.
Parameters:
  template - The template name.
public  voidinit()
     Called the first time the Service is used.
public  booleanisCaching()
    
public synchronized  voidregisterTemplateEngineService(TemplateEngineService service)
     Registers the provided template engine for use by the TemplateService.
public  booleantemplateExists(String template, String[] templatePaths)
     Delegates to the appropriate org.apache.turbine.services.template.TemplateEngineService to check the existance of the specified template.
public  String[]translateTemplatePaths(String[] templatePaths)
     Translates the supplied template paths into their Turbine-canonical equivalent (probably absolute paths).

Field Detail
LAYOUT_KEY
final public static int LAYOUT_KEY(Code)
Represents Layout Objects



LAYOUT_NAME
final public static String LAYOUT_NAME(Code)
Represents Layout Objects



LAYOUT_TEMPLATE_KEY
final public static int LAYOUT_TEMPLATE_KEY(Code)
Represents Layout Template Objects



LAYOUT_TEMPLATE_NAME
final public static String LAYOUT_TEMPLATE_NAME(Code)
Represents Layout Template Objects



NAVIGATION_KEY
final public static int NAVIGATION_KEY(Code)
Represents Navigation Objects



NAVIGATION_NAME
final public static String NAVIGATION_NAME(Code)
Represents Navigation Objects



NAVIGATION_TEMPLATE_KEY
final public static int NAVIGATION_TEMPLATE_KEY(Code)
Represents Navigation Template Objects



NAVIGATION_TEMPLATE_NAME
final public static String NAVIGATION_TEMPLATE_NAME(Code)
Represents Navigation Template Objects



NO_FILE_EXT
final protected static String NO_FILE_EXT(Code)
The default file extension used as a registry key when a template's file extension cannot be determined. Use TemplateService.DEFAULT_EXTENSION_VALUE.



PAGE_KEY
final public static int PAGE_KEY(Code)
Represents Page Objects



PAGE_NAME
final public static String PAGE_NAME(Code)
Represents Page Objects



SCREEN_KEY
final public static int SCREEN_KEY(Code)
Represents Screen Objects



SCREEN_NAME
final public static String SCREEN_NAME(Code)
Represents Screen Objects



SCREEN_TEMPLATE_KEY
final public static int SCREEN_TEMPLATE_KEY(Code)
Represents Screen Template Objects



SCREEN_TEMPLATE_NAME
final public static String SCREEN_TEMPLATE_NAME(Code)
Represents Screen Template Objects



TEMPLATE_TYPES
final public static int TEMPLATE_TYPES(Code)
Number of different Template Types that we know of




Constructor Detail
TurbineTemplateService
public TurbineTemplateService()(Code)
C'tor




Method Detail
getDefaultExtension
public String getDefaultExtension()(Code)
Get the default template name extension specified in the template service properties. If no extension is defined, return the empty string. The default extension.



getDefaultLayout
public String getDefaultLayout()(Code)
Get the default layout module name of the template engine service corresponding to the default template name extension. The default layout module name.



getDefaultLayoutName
public String getDefaultLayoutName(String template)(Code)
Get the default layout module name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name. The default layout module name.



getDefaultLayoutName
public String getDefaultLayoutName(RunData data)(Code)
Find the default layout module name for the given request.
Parameters:
  data - The encapsulation of the request to retrieve thedefault layout for. The default layout module name.



getDefaultLayoutTemplate
public String getDefaultLayoutTemplate()(Code)
Get the default layout template name of the template engine service corresponding to the default template name extension. The default layout template name.



getDefaultLayoutTemplateName
public String getDefaultLayoutTemplateName(String template)(Code)
Get the default layout template name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name. The default layout template name.



getDefaultNavigation
public String getDefaultNavigation()(Code)
Get the default navigation module name of the template engine service corresponding to the default template name extension. The default navigation module name.



getDefaultNavigationName
public String getDefaultNavigationName(String template)(Code)
Get the default navigation module name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name. The default navigation module name.



getDefaultPage
public String getDefaultPage()(Code)
Get the default page module name of the template engine service corresponding to the default template name extension. The default page module name.



getDefaultPageName
public String getDefaultPageName(String template)(Code)
Get the default page module name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name. The default page module name.



getDefaultPageName
public String getDefaultPageName(RunData data)(Code)
Find the default page module name for the given request.
Parameters:
  data - The encapsulation of the request to retrieve thedefault page for. The default page module name.



getDefaultScreen
public String getDefaultScreen()(Code)
Get the default screen module name of the template engine service corresponding to the default template name extension. The default screen module name.



getDefaultScreenName
public String getDefaultScreenName(String template)(Code)
Get the default screen module name of the template engine service corresponding to the template name extension of the named template.
Parameters:
  template - The template name. The default screen module name.



getDefaultTemplate
public String getDefaultTemplate()(Code)
Returns the Default Template Name with the Default Extension. If the extension is unset, return only the template name The default template Name



getExtension
public String getExtension(String template)(Code)
Return Extension for a supplied template
Parameters:
  template - The template name extension The extension for the supplied template



getLayoutName
public String getLayoutName(String template) throws Exception(Code)
Locate and return the name of the layout module to be used with the named layout template.
Parameters:
  template - The layout template name. The found layout module name.
exception:
  Exception - , a generic exception.



getLayoutTemplateName
public String getLayoutTemplateName(String template) throws Exception(Code)
Locate and return the name of the layout template corresponding to the given screen template name parameter.
Parameters:
  template - The template name parameter. The found screen template name.
exception:
  Exception - , a generic exception.



getNavigationName
public String getNavigationName(String template) throws Exception(Code)
Locate and return the name of the navigation module to be used with the named navigation template.
Parameters:
  template - The navigation template name. The found navigation module name.
exception:
  Exception - , a generic exception.



getNavigationTemplateName
public String getNavigationTemplateName(String template) throws Exception(Code)
Locate and return the name of the navigation template corresponding to the given template name parameter. This might return null if the navigation is not found!
Parameters:
  template - The template name parameter. The found navigation template name.
exception:
  Exception - , a generic exception.



getScreenName
public String getScreenName(String template) throws Exception(Code)
Locate and return the name of the screen module to be used with the named screen template.
Parameters:
  template - The screen template name. The found screen module name.
exception:
  Exception - , a generic exception.



getScreenTemplateName
public String getScreenTemplateName(String template) throws Exception(Code)
Locate and return the name of the screen template corresponding to the given template name parameter. This might return null if the screen is not found!
Parameters:
  template - The template name parameter. The found screen template name.
exception:
  Exception - , a generic exception.



getTemplateEngineService
public TemplateEngineService getTemplateEngineService(String template)(Code)
The org.apache.turbine.services.template.TemplateEngineService associated with the specified template's file extension.
Parameters:
  template - The template name. The template engine service.



init
public void init() throws InitializationException(Code)
Called the first time the Service is used.
exception:
  InitializationException - Something went wrong whensetting up the Template Service.



isCaching
public boolean isCaching()(Code)
Returns true if the Template Service has caching activated true if Caching is active.



registerTemplateEngineService
public synchronized void registerTemplateEngineService(TemplateEngineService service)(Code)
Registers the provided template engine for use by the TemplateService.
Parameters:
  service - The TemplateEngineService to register.



templateExists
public boolean templateExists(String template, String[] templatePaths)(Code)
Delegates to the appropriate org.apache.turbine.services.template.TemplateEngineService to check the existance of the specified template.
Parameters:
  template - The template to check for the existance of.
Parameters:
  templatePaths - The paths to check for the template.



translateTemplatePaths
public String[] translateTemplatePaths(String[] templatePaths)(Code)
Translates the supplied template paths into their Turbine-canonical equivalent (probably absolute paths). This is used if the templating engine (e.g. JSP) does not provide any means to load a page but the page path is passed to the servlet container.
Parameters:
  templatePaths - An array of template paths. An array of translated template paths.



Methods inherited from org.apache.turbine.services.TurbineBaseService
public void init(Object data) throws InitializationException(Code)(Java Doc)
public void init(ServletConfig config) throws InitializationException(Code)(Java Doc)
public void init(RunData data) throws InitializationException(Code)(Java Doc)
public void init() throws InitializationException(Code)(Java Doc)
public void shutdown()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.