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
- createTemplateLoader method
- populateContext method

createConfiguration method
Create a freemarker Configuration.

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

createTemplateLoader 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`
`static String` | `ATTR_TEMPLATE_MODEL`
`protected boolean` | `cacheBeanWrapper`
`protected freemarker.template.Configuration` | `config`
`static String` | `CONFIG_SERVLET_CONTEXT_KEY`
`protected String` | `contentType`
`protected boolean` | `debug`
`static String` | `DEFAULT_CONTENT_TYPE`
`protected String` | `encoding`
`static String` | `EXPIRATION_DATE`
`static String` | `INITPARAM_CONTENT_TYPE`
`static String` | `INITPARAM_DEBUG`
`static String` | `INITPARAM_NOCACHE`
`static String` | `INITPARAM_TEMPLATE_PATH`
`static String` | `KEY_APPLICATION`
`static String` | `KEY_APPLICATION_PRIVATE`
`static String` | `KEY_EXCEPTION`
`static String` | `KEY_HASHMODEL_PRIVATE`
`static String` | `KEY_INCLUDE`
`static String` | `KEY_JSP_TAGLIBS`
`static String` | `KEY_REQUEST`
`static String` | `KEY_REQUEST_PARAMETERS`
`static String` | `KEY_REQUEST_PARAMETERS_STRUTS`
`static String` | `KEY_REQUEST_PRIVATE`
`static String` | `KEY_SESSION`
`protected int` | `mruMaxStrongSize`
`protected boolean` | `nocache`
`protected boolean` | `noCharsetInContentType`
`protected Map<String,TagLibrary>` | `oldTagLibraries`
`protected Map<String,TagLibraryModelProvider>` | `tagLibraries`
`protected String` | `templatePath`
`protected String` | `templateUpdateDelay`
`protected freemarker.template.ObjectWrapper` | `wrapper`

Constructor Summary
`FreemarkerManager()`

Method Summary
`void` | `addSetting(String name, String value)`
`protected ScopesHashModel` | `buildScopesHashModel(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, freemarker.template.ObjectWrapper wrapper, ValueStack stack)`
`ScopesHashModel` | `buildTemplateModel(ValueStack stack, Object action, javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, freemarker.template.ObjectWrapper wrapper)`
`protected void` | `configureTemplateLoader(freemarker.cache.TemplateLoader templateLoader)` Sets the Freemarker Configuration's template loader with the FreemarkerThemeTemplateLoader at the top.
`protected freemarker.template.Configuration` | `createConfiguration(javax.servlet.ServletContext servletContext)` Create the instance of the freemarker Configuration object.
`protected freemarker.template.ObjectWrapper` | `createObjectWrapper(javax.servlet.ServletContext servletContext)`
`protected freemarker.cache.TemplateLoader` | `createTemplateLoader(javax.servlet.ServletContext servletContext, String templatePath)` Create the template loader.
`freemarker.template.Configuration` | `getConfig()`
`freemarker.template.Configuration` | `getConfiguration(javax.servlet.ServletContext servletContext)`
`String` | `getContentType()`
`boolean` | `getDebug()`
`boolean` | `getNocache()`
`boolean` | `getNoCharsetInContentType()`
`String` | `getTemplatePath()`
`freemarker.template.ObjectWrapper` | `getWrapper()`
`void` | `init(javax.servlet.ServletContext servletContext)`
`protected void` | `loadSettings(javax.servlet.ServletContext servletContext)` Load the settings from the /freemarker.properties file on the classpath
`protected void` | `populateContext(ScopesHashModel model, ValueStack stack, Object action, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)`
`void` | `setCacheBeanWrapper(String val)`
`void` | `setContainer(Container container)`
`void` | `setEncoding(String encoding)`
`void` | `setFileManagerFactory(FileManagerFactory fileManagerFactory)`
`void` | `setMruMaxStrongSize(String size)`
`void` | `setTemplateUpdateDelay(String delay)`
`void` | `setThemeTemplateLoader(FreemarkerThemeTemplateLoader themeTemplateLoader)`
`void` | `setWrapperAltMap(String val)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INITPARAM_TEMPLATE_PATH

    public static final String INITPARAM_TEMPLATE_PATH

See Also:
  Constant Field Values

### INITPARAM_NOCACHE

    public static final String INITPARAM_NOCACHE

See Also:
  Constant Field Values

### INITPARAM_CONTENT_TYPE

    public static final String INITPARAM_CONTENT_TYPE

See Also:
  Constant Field Values

### DEFAULT_CONTENT_TYPE

    public static final String DEFAULT_CONTENT_TYPE

See Also:
  Constant Field Values

### INITPARAM_DEBUG

    public static final String INITPARAM_DEBUG

See Also:
  Constant Field Values

### KEY_REQUEST

    public static final String KEY_REQUEST

See Also:
  Constant Field Values

### KEY_INCLUDE

    public static final String KEY_INCLUDE

See Also:
  Constant Field Values

### KEY_REQUEST_PRIVATE

    public static final String KEY_REQUEST_PRIVATE

See Also:
  Constant Field Values

### KEY_REQUEST_PARAMETERS

    public static final String KEY_REQUEST_PARAMETERS

See Also:
  Constant Field Values

### KEY_SESSION

    public static final String KEY_SESSION

See Also:
  Constant Field Values

### KEY_APPLICATION

    public static final String KEY_APPLICATION

See Also:
  Constant Field Values

### KEY_APPLICATION_PRIVATE

    public static final String KEY_APPLICATION_PRIVATE

See Also:
  Constant Field Values

### KEY_JSP_TAGLIBS

    public static final String KEY_JSP_TAGLIBS

See Also:
  Constant Field Values

### ATTR_TEMPLATE_MODEL

    public static final String ATTR_TEMPLATE_MODEL

See Also:
  Constant Field Values

### KEY_REQUEST_PARAMETERS_STRUTS

    public static final String KEY_REQUEST_PARAMETERS_STRUTS

See Also:
  Constant Field Values

### KEY_HASHMODEL_PRIVATE

    public static final String KEY_HASHMODEL_PRIVATE

See Also:
  Constant Field Values

### EXPIRATION_DATE

    public static final String EXPIRATION_DATE

### 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

### templatePath

    protected String templatePath

### nocache

    protected boolean nocache

### debug

    protected boolean debug

### config

    protected freemarker.template.Configuration config

### wrapper

    protected freemarker.template.ObjectWrapper wrapper

### contentType

    protected String contentType

### noCharsetInContentType

    protected boolean noCharsetInContentType

### encoding

    protected String encoding

### altMapWrapper

    protected boolean altMapWrapper

### cacheBeanWrapper

    protected boolean cacheBeanWrapper

### mruMaxStrongSize

    protected int mruMaxStrongSize

### templateUpdateDelay

    protected String templateUpdateDelay

### tagLibraries

    protected Map<String,TagLibraryModelProvider> tagLibraries

### oldTagLibraries

    protected Map<String,TagLibrary> oldTagLibraries

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)

### setTemplateUpdateDelay

    public void setTemplateUpdateDelay(String delay)

### setContainer

    public void setContainer(Container container)

### setFileManagerFactory

    public void setFileManagerFactory(FileManagerFactory fileManagerFactory)

### setThemeTemplateLoader

    public void setThemeTemplateLoader(FreemarkerThemeTemplateLoader themeTemplateLoader)

### getNoCharsetInContentType

    public boolean getNoCharsetInContentType()

### getTemplatePath

    public String getTemplatePath()

### getNocache

    public boolean getNocache()

### getDebug

    public boolean getDebug()

### getConfig

    public freemarker.template.Configuration getConfig()

### getWrapper

    public freemarker.template.ObjectWrapper getWrapper()

### getContentType

    public String getContentType()

### getConfiguration

    public freemarker.template.Configuration getConfiguration(javax.servlet.ServletContext servletContext)

### init

    public void init(javax.servlet.ServletContext servletContext)
              throws freemarker.template.TemplateException

  Throws:
    `freemarker.template.TemplateException`

### configureTemplateLoader

    protected void configureTemplateLoader(freemarker.cache.TemplateLoader templateLoader)

  Sets the Freemarker Configuration's template loader with the FreemarkerThemeTemplateLoader at the top.

  See Also:
    `FreemarkerThemeTemplateLoader`

### createConfiguration

    protected freemarker.template.Configuration createConfiguration(javax.servlet.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`

### buildScopesHashModel

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

### createObjectWrapper

    protected freemarker.template.ObjectWrapper createObjectWrapper(javax.servlet.ServletContext servletContext)

### createTemplateLoader

    protected freemarker.cache.TemplateLoader createTemplateLoader(javax.servlet.ServletContext servletContext,
                                                                   String templatePath)

  Create the template loader. The default implementation will create a `ClassTemplateLoader` if the template path starts with "class://", a `FileTemplateLoader` if the template path starts with "file://", and a `WebappTemplateLoader` otherwise.

  Parameters:
    `templatePath` - the template path to create a loader for
  Returns:
    a newly created template loader
  Throws:
    `IOException`

### loadSettings

    protected void loadSettings(javax.servlet.ServletContext servletContext)

  Load the settings from the /freemarker.properties file on the classpath

  See Also:
    `for the definition of valid settings`

### addSetting

    public void addSetting(String name,
                           String value)
                    throws freemarker.template.TemplateException

  Throws:
    `freemarker.template.TemplateException`

### buildTemplateModel

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

### populateContext

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

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–2017 Apache Software Foundation. All rights reserved.