org.apache.struts2.components.template
Class FreemarkerTemplateEngine

java.lang.Object
  extended by org.apache.struts2.components.template.BaseTemplateEngine
      extended by org.apache.struts2.components.template.FreemarkerTemplateEngine
All Implemented Interfaces:
TemplateEngine

public class FreemarkerTemplateEngine
extends BaseTemplateEngine

Freemarker based template engine.


Field Summary
(package private) static Class bodyContent
           
private  boolean freemarkerCaching
           
private  FreemarkerManager freemarkerManager
           
private static Log LOG
           
private  HashSet<String> missingTemplates
           
private  HashMap<String,freemarker.template.Template> templates
           
 
Fields inherited from class org.apache.struts2.components.template.BaseTemplateEngine
DEFAULT_THEME_PROPERTIES_FILE_NAME, themeProps
 
Constructor Summary
FreemarkerTemplateEngine()
           
 
Method Summary
protected  void addToCache(String templateName, freemarker.template.Template template)
           
protected  void addToMissingTemplateCache(String templateName)
           
protected  freemarker.template.Template findInCache(String templateName)
           
protected  String getSuffix()
           
protected  boolean isTemplateMissing(String templateName)
           
 void renderTemplate(TemplateRenderingContext templateContext)
          Renders the template
 void setCacheTemplates(String cacheTemplates)
          Enables or disables Struts caching of Freemarker templates.
 void setFreemarkerManager(FreemarkerManager mgr)
           
 
Methods inherited from class org.apache.struts2.components.template.BaseTemplateEngine
getFinalTemplateName, getThemePropertiesFileName, getThemeProps
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bodyContent

static Class bodyContent

freemarkerManager

private FreemarkerManager freemarkerManager

templates

private final HashMap<String,freemarker.template.Template> templates

missingTemplates

private final HashSet<String> missingTemplates

freemarkerCaching

private boolean freemarkerCaching

LOG

private static final Log LOG
Constructor Detail

FreemarkerTemplateEngine

public FreemarkerTemplateEngine()
Method Detail

setFreemarkerManager

public void setFreemarkerManager(FreemarkerManager mgr)

renderTemplate

public void renderTemplate(TemplateRenderingContext templateContext)
                    throws Exception
Description copied from interface: TemplateEngine
Renders the template

Parameters:
templateContext - context for the given template.
Throws:
Exception - is thrown if there is a failure when rendering.

getSuffix

protected String getSuffix()
Specified by:
getSuffix in class BaseTemplateEngine

addToMissingTemplateCache

protected void addToMissingTemplateCache(String templateName)

isTemplateMissing

protected boolean isTemplateMissing(String templateName)

addToCache

protected void addToCache(String templateName,
                          freemarker.template.Template template)

findInCache

protected freemarker.template.Template findInCache(String templateName)

setCacheTemplates

public void setCacheTemplates(String cacheTemplates)
Enables or disables Struts caching of Freemarker templates. By default disabled. Set struts.freemarker.templatesCache=true to enable cache

Parameters:
cacheTemplates - "true" if the template engine should cache freemarker template internally


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