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
           
protected  boolean freemarkerCaching
           
protected  FreemarkerManager freemarkerManager
           
private static Logger LOG
           
protected  Set<String> missingTemplates
           
protected  Map<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)
           
 void clearTemplatesCache()
          Clear the templates and missing templates cache
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

protected FreemarkerManager freemarkerManager

templates

protected final Map<String,freemarker.template.Template> templates

missingTemplates

protected final Set<String> missingTemplates

freemarkerCaching

protected boolean freemarkerCaching

LOG

private static final Logger 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

clearTemplatesCache

public void clearTemplatesCache()
Clear the templates and missing templates cache



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