Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » views » freemarker » [javadoc | source]
org.apache.struts2.views.freemarker
public class: FreemarkerManager [javadoc | source]
java.lang.Object
   org.apache.struts2.views.freemarker.FreemarkerManager

Direct Known Subclasses:
    CustomFreemarkerManager

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
public static final  String CONFIG_SERVLET_CONTEXT_KEY     
public static final  String KEY_EXCEPTION     
public static final  String KEY_APPLICATION     
public static final  String KEY_REQUEST_MODEL     
public static final  String KEY_SESSION_MODEL     
public static final  String KEY_JSP_TAGLIBS     
public static final  String KEY_REQUEST_PARAMETER_MODEL     
Method from org.apache.struts2.views.freemarker.FreemarkerManager Summary:
buildScopesHashModel,   buildTemplateModel,   createConfiguration,   getConfiguration,   getObjectWrapper,   getTemplateLoader,   loadSettings,   populateContext,   setContainer,   setEncoding,   setWrapperAltMap
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.views.freemarker.FreemarkerManager Detail:
 protected ScopesHashModel buildScopesHashModel(ServletContext servletContext,
    HttpServletRequest request,
    HttpServletResponse response,
    ObjectWrapper wrapper,
    ValueStack stack) 
 public SimpleHash buildTemplateModel(ValueStack stack,
    Object action,
    ServletContext servletContext,
    HttpServletRequest request,
    HttpServletResponse response,
    ObjectWrapper wrapper) 
 protected Configuration createConfiguration(ServletContext servletContext) throws 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
 public final synchronized Configuration getConfiguration(ServletContext servletContext) throws TemplateException 
 protected BeansWrapper getObjectWrapper() 
 protected 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

 protected  void loadSettings(ServletContext servletContext,
    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) 
 public  void setContainer(Container container) 
 public  void setEncoding(String encoding) 
 public  void setWrapperAltMap(String val)