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 :-
- path defined in ServletContext init parameter named 'templatePath' or 'TemplatePath' (must be an absolute path)
- webapp classpath
- struts's static folder (under [STRUT2_SOURCE]/org/apache/struts2/static/
populateContext method
populate the created model.
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 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 |
setFileManager(FileManager fileManager)
|
void |
setMruMaxStrongSize(String size)
|
void |
setTemplateUpdateDelay(String delay)
|
void |
setWrapperAltMap(String val)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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,TagLibrary> tagLibraries
FreemarkerManager
public FreemarkerManager()
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)
setFileManager
public void setFileManager(FileManager fileManager)
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
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)
Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.