com.opensymphony.webwork.views.freemarker
Class FreemarkerManager

java.lang.Object
  extended by com.opensymphony.webwork.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. webwork's static folder (under [WEBWORK_SOURCE]/com/opensymphony/webwork/static/

populateContext method
populate the created model.

Version:
$Date: 2007-03-10 19:42:13 +0800 (Sat, 10 Mar 2007) $ $Id: FreemarkerManager.java 2859 2007-03-10 11:42:13Z tm_jee $
Author:
CameronBraid, tm_jee

Field Summary
static String CONFIG_SERVLET_CONTEXT_KEY
           
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
           
 
Constructor Summary
FreemarkerManager()
           
 
Method Summary
protected  ScopesHashModel buildScopesHashModel(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, freemarker.template.ObjectWrapper wrapper, OgnlValueStack stack)
           
 freemarker.template.SimpleHash buildTemplateModel(OgnlValueStack 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)
           
static FreemarkerManager getInstance()
          To allow for custom configuration of freemarker, sublcass this class "ConfigManager" and set the webwork configuration property webwork.freemarker.configmanager.classname to the fully qualified classname.
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
 void populateContext(ScopesHashModel model, OgnlValueStack stack, Object action, HttpServletRequest request, HttpServletResponse response)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

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
Constructor Detail

FreemarkerManager

public FreemarkerManager()
Method Detail

getInstance

public static final FreemarkerManager getInstance()
To allow for custom configuration of freemarker, sublcass this class "ConfigManager" and set the webwork configuration property webwork.freemarker.configmanager.classname to the fully qualified classname.

This allows you to override the protected methods in the ConfigMangaer to programatically create your own Configuration instance


getConfiguration

public final 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,
                                               OgnlValueStack stack)

populateContext

public void populateContext(ScopesHashModel model,
                            OgnlValueStack 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(OgnlValueStack stack,
                                                         Object action,
                                                         ServletContext servletContext,
                                                         HttpServletRequest request,
                                                         HttpServletResponse response,
                                                         freemarker.template.ObjectWrapper wrapper)

WebWork Project Page