Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.views.freemarker
Class FreemarkerManager

    java.lang.Object
      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
- loadSettings method
- getTemplateLoader method
- populateContext method

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
`private boolean` | `altMapWrapper`
`private static String` | `ATTR_APPLICATION_MODEL`
`private static String` | `ATTR_JSP_TAGLIBS_MODEL`
`private static String` | `ATTR_REQUEST_MODEL`
`private static String` | `ATTR_REQUEST_PARAMETERS_MODEL`
`static String` | `CONFIG_SERVLET_CONTEXT_KEY`
`private 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 Log` | `log`
`private 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` | `setContainer(Container container)`
`void` | `setEncoding(String encoding)`
`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 Log 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

    private static final String ATTR_APPLICATION_MODEL

See Also:
  Constant Field Values

### ATTR_JSP_TAGLIBS_MODEL

    private static final String ATTR_JSP_TAGLIBS_MODEL

See Also:
  Constant Field Values

### ATTR_REQUEST_MODEL

    private static final String ATTR_REQUEST_MODEL

See Also:
  Constant Field Values

### ATTR_REQUEST_PARAMETERS_MODEL

    private 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

    private String encoding

### altMapWrapper

    private boolean altMapWrapper

### tagLibraries

    private Map<String,TagLibrary> tagLibraries

Constructor Detail

### FreemarkerManager

    public FreemarkerManager()

Method Detail

### setEncoding

    public void setEncoding(String encoding)

### setWrapperAltMap

    public void setWrapperAltMap(String val)

### setContainer

    public void setContainer(Container container)

### 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,
                                                   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
  - obtains the default configuration from Configuration.getDefaultConfiguration()
  - sets up template loading from a ClassTemplateLoader and a WebappTemplateLoader
  - sets up the object wrapper to be the BeansWrapper
  - loads settings from the classpath file /freemarker.properties

  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)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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