org.apache.struts2.views.freemarker
Class FreemarkerManager

java.lang.Object
  extended by org.apache.struts2.views.freemarker.FreemarkerManager

public class FreemarkerManager
extends Object

Static Configuration Manager for the FreemarkerResult's configuration

Possible extension points are :-

createConfiguration method
Create a freemarker Configuration.

loadSettings method
Load freemarker settings, default to freemarker.properties (if found in classpath)

getTemplateLoader method
create a freemarker TemplateLoader that loads freemarker template in the following order :-

  1. path defined in ServletContext init parameter named 'templatePath' or 'TemplatePath' (must be an absolute path)
  2. webapp classpath
  3. struts's static folder (under [STRUT2_SOURCE]/org/apache/struts2/static/

populateContext method
populate the created model.


Field Summary
protected  boolean altMapWrapper
           
protected static String ATTR_APPLICATION_MODEL
           
protected static String ATTR_JSP_TAGLIBS_MODEL
           
protected static String ATTR_REQUEST_MODEL
           
protected static String ATTR_REQUEST_PARAMETERS_MODEL
           
protected  boolean cacheBeanWrapper
           
static String CONFIG_SERVLET_CONTEXT_KEY
           
protected  String encoding
           
static String KEY_APPLICATION
           
static String KEY_EXCEPTION
           
static String KEY_JSP_TAGLIBS
           
static String KEY_REQUEST_MODEL
           
static String KEY_REQUEST_PARAMETER_MODEL
           
static String KEY_SESSION_MODEL
           
private static Logger LOG
           
protected  int mruMaxStrongSize
           
protected  Map<String,TagLibrary> tagLibraries
           
 
Constructor Summary
FreemarkerManager()
           
 
Method Summary
protected  ScopesHashModel buildScopesHashModel(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, freemarker.template.ObjectWrapper wrapper, ValueStack stack)
           
 freemarker.template.SimpleHash buildTemplateModel(ValueStack stack, Object action, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, freemarker.template.ObjectWrapper wrapper)
           
protected  freemarker.template.Configuration createConfiguration(ServletContext servletContext)
          Create the instance of the freemarker Configuration object.
 freemarker.template.Configuration getConfiguration(ServletContext servletContext)
           
protected  freemarker.ext.beans.BeansWrapper getObjectWrapper()
           
protected  freemarker.cache.TemplateLoader getTemplateLoader(ServletContext servletContext)
          The default template loader is a MultiTemplateLoader which includes a ClassTemplateLoader and a WebappTemplateLoader (and a FileTemplateLoader depending on the init-parameter 'TemplatePath').
protected  void loadSettings(ServletContext servletContext, freemarker.template.Configuration configuration)
          Load the settings from the /freemarker.properties file on the classpath
protected  void populateContext(ScopesHashModel model, ValueStack stack, Object action, HttpServletRequest request, HttpServletResponse response)
           
 void setCacheBeanWrapper(String val)
           
 void setContainer(Container container)
           
 void setEncoding(String encoding)
           
 void setMruMaxStrongSize(String size)
           
 void setWrapperAltMap(String val)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final Logger LOG

CONFIG_SERVLET_CONTEXT_KEY

public static final String CONFIG_SERVLET_CONTEXT_KEY
See Also:
Constant Field Values

KEY_EXCEPTION

public static final String KEY_EXCEPTION
See Also:
Constant Field Values

ATTR_APPLICATION_MODEL

protected static final String ATTR_APPLICATION_MODEL
See Also:
Constant Field Values

ATTR_JSP_TAGLIBS_MODEL

protected static final String ATTR_JSP_TAGLIBS_MODEL
See Also:
Constant Field Values

ATTR_REQUEST_MODEL

protected static final String ATTR_REQUEST_MODEL
See Also:
Constant Field Values

ATTR_REQUEST_PARAMETERS_MODEL

protected static final String ATTR_REQUEST_PARAMETERS_MODEL
See Also:
Constant Field Values

KEY_APPLICATION

public static final String KEY_APPLICATION
See Also:
Constant Field Values

KEY_REQUEST_MODEL

public static final String KEY_REQUEST_MODEL
See Also:
Constant Field Values

KEY_SESSION_MODEL

public static final String KEY_SESSION_MODEL
See Also:
Constant Field Values

KEY_JSP_TAGLIBS

public static final String KEY_JSP_TAGLIBS
See Also:
Constant Field Values

KEY_REQUEST_PARAMETER_MODEL

public static final String KEY_REQUEST_PARAMETER_MODEL
See Also:
Constant Field Values

encoding

protected String encoding

altMapWrapper

protected boolean altMapWrapper

cacheBeanWrapper

protected boolean cacheBeanWrapper

mruMaxStrongSize

protected int mruMaxStrongSize

tagLibraries

protected Map<String,TagLibrary> tagLibraries
Constructor Detail

FreemarkerManager

public FreemarkerManager()
Method Detail

setEncoding

public void setEncoding(String encoding)

setWrapperAltMap

public void setWrapperAltMap(String val)

setCacheBeanWrapper

public void setCacheBeanWrapper(String val)

setMruMaxStrongSize

public void setMruMaxStrongSize(String size)

setContainer

public void setContainer(Container container)

getConfiguration

public freemarker.template.Configuration getConfiguration(ServletContext servletContext)
                                                   throws freemarker.template.TemplateException
Throws:
freemarker.template.TemplateException

buildScopesHashModel

protected ScopesHashModel buildScopesHashModel(ServletContext servletContext,
                                               HttpServletRequest request,
                                               HttpServletResponse response,
                                               freemarker.template.ObjectWrapper wrapper,
                                               ValueStack stack)

populateContext

protected void populateContext(ScopesHashModel model,
                               ValueStack stack,
                               Object action,
                               HttpServletRequest request,
                               HttpServletResponse response)

getObjectWrapper

protected freemarker.ext.beans.BeansWrapper getObjectWrapper()

getTemplateLoader

protected freemarker.cache.TemplateLoader getTemplateLoader(ServletContext servletContext)
The default template loader is a MultiTemplateLoader which includes a ClassTemplateLoader and a WebappTemplateLoader (and a FileTemplateLoader depending on the init-parameter 'TemplatePath').

The ClassTemplateLoader will resolve fully qualified template includes that begin with a slash. for example /com/company/template/common.ftl

The WebappTemplateLoader attempts to resolve templates relative to the web root folder


createConfiguration

protected freemarker.template.Configuration createConfiguration(ServletContext servletContext)
                                                         throws freemarker.template.TemplateException
Create the instance of the freemarker Configuration object.

this implementation

Parameters:
servletContext -
Throws:
freemarker.template.TemplateException

loadSettings

protected void loadSettings(ServletContext servletContext,
                            freemarker.template.Configuration configuration)
Load the settings from the /freemarker.properties file on the classpath

See Also:
for the definition of valid settings

buildTemplateModel

public freemarker.template.SimpleHash buildTemplateModel(ValueStack stack,
                                                         Object action,
                                                         ServletContext servletContext,
                                                         HttpServletRequest request,
                                                         HttpServletResponse response,
                                                         freemarker.template.ObjectWrapper wrapper)


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