org.apache.struts2.components.template
Class TemplateEngineManager

java.lang.Object
  extended by org.apache.struts2.components.template.TemplateEngineManager

public class TemplateEngineManager
extends Object

The TemplateEngineManager will return a template engine for the template


Nested Class Summary
(package private) static interface TemplateEngineManager.EngineFactory
          Abstracts loading of the template engine
(package private)  class TemplateEngineManager.LazyEngineFactory
          Allows the template engine to be loaded at request time, so that engines that are missing dependencies aren't accessed if never used.
 
Field Summary
(package private)  Container container
           
static String DEFAULT_TEMPLATE_TYPE
          The default template extenstion is ftl.
static String DEFAULT_TEMPLATE_TYPE_CONFIG_KEY
           
(package private)  String defaultTemplateType
           
(package private)  Map<String,TemplateEngineManager.EngineFactory> templateEngines
           
 
Constructor Summary
TemplateEngineManager()
           
 
Method Summary
 TemplateEngine getTemplateEngine(Template template, String templateTypeOverride)
          Gets the TemplateEngine for the template name.
 void registerTemplateEngine(String templateExtension, TemplateEngine templateEngine)
          Registers the given template engine.
 void setContainer(Container container)
           
 void setDefaultTemplateType(String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TEMPLATE_TYPE_CONFIG_KEY

public static final String DEFAULT_TEMPLATE_TYPE_CONFIG_KEY
See Also:
Constant Field Values

DEFAULT_TEMPLATE_TYPE

public static final String DEFAULT_TEMPLATE_TYPE
The default template extenstion is ftl.

See Also:
Constant Field Values

templateEngines

Map<String,TemplateEngineManager.EngineFactory> templateEngines

container

Container container

defaultTemplateType

String defaultTemplateType
Constructor Detail

TemplateEngineManager

public TemplateEngineManager()
Method Detail

setDefaultTemplateType

public void setDefaultTemplateType(String type)

setContainer

public void setContainer(Container container)

registerTemplateEngine

public void registerTemplateEngine(String templateExtension,
                                   TemplateEngine templateEngine)
Registers the given template engine.

Will add the engine to the existing list of known engines.

Parameters:
templateExtension - filename extension (eg. .jsp, .ftl, .vm).
templateEngine - the engine.

getTemplateEngine

public TemplateEngine getTemplateEngine(Template template,
                                        String templateTypeOverride)
Gets the TemplateEngine for the template name. If the template name has an extension (for instance foo.jsp), then this extension will be used to look up the appropriate TemplateEngine. If it does not have an extension, it will look for a Configuration setting "struts.ui.templateSuffix" for the extension, and if that is not set, it will fall back to "ftl" as the default.

Parameters:
template - Template used to determine which TemplateEngine to return
templateTypeOverride - Overrides the default template type
Returns:
the engine.


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.