| java.lang.Object com.opensymphony.webwork.dispatcher.WebWorkResultSupport com.opensymphony.webwork.views.freemarker.FreemarkerResult
FreemarkerResult | public class FreemarkerResult extends WebWorkResultSupport (Code) | |
Renders a view using the Freemarker template engine. Alternatively, the
com.opensymphony.webwork.dispatcher.ServletDispatcherResultdispatcher result type can be used in conjunction Webwork's
FreemarkerServlet .
The FreemarkarManager class configures the template loaders so that the
template location can be either
- relative to the web root folder. eg
/WEB-INF/views/home.ftl
- a classpath resuorce. eg
com/company/web/views/home.ftl
NOTE (bufferOutput attribute):
Allow customization of either (when true) to write result to response
stream/writer only when everything is ok (without exception) or otherwise.
This is usefull when using Freemarker's "rethrow" exception handler, where we
don't want partial of the page to be writen and then exception occurred and
we have freemarker's "rethrow" exception handler to take over but its too late
since part of the response has already been 'commited' to the stream/writer.
This result type takes the following parameters:
- location (default) - the location of the template to process.
- parse - true by default. If set to false, the location param
will not be parsed for Ognl expressions.
- contentType - defaults to "text/html" unless specified.
- bufferOutput - default to false. If true, will only write to
the response if the whole freemarker page could be rendered ok.
Example:
<!-- START SNIPPET: example -->
<result name="success" type="freemarker">foo.ftl</result>
<!-- END SNIPPET: example -->
author: CameronBraid |
bufferOutput | protected boolean bufferOutput(Code) | | |
configuration | protected Configuration configuration(Code) | | |
wrapper | protected ObjectWrapper wrapper(Code) | | |
createModel | protected TemplateModel createModel() throws TemplateModelException(Code) | | Build the instance of the ScopesHashModel, including JspTagLib support
Objects added to the model are
- Application - servlet context attributes hash model
- JspTaglibs - jsp tag lib factory model
- Request - request attributes hash model
- Session - session attributes hash model
- req - the HttpServletRequst object for direct access
- res - the HttpServletResponse object for direct access
- stack - the OgnLValueStack instance for direct access
- ognl - the instance of the OgnlTool
- action - the action itself
- exception - optional : the JSP or Servlet exception as per the servlet spec (for JSP Exception pages)
- webwork - instance of the WebWorkUtil class
|
deduceLocale | protected Locale deduceLocale()(Code) | | Returns the locale used for the
Configuration.getTemplate(StringLocale) call. The base implementation
simply returns the locale setting of the action (assuming the action implements
LocaleProvider ) or, if
the action does not the configuration's locale is returned. Override this method to provide different behaviour,
|
doExecute | public void doExecute(String location, ActionInvocation invocation) throws IOException, TemplateException(Code) | | Execute this result, using the specified template location.
The template location has already been interoplated for any variable substitutions
this method obtains the freemarker configuration and the object wrapper from the provided hooks.
It them implements the template processing workflow by calling the hooks for
preTemplateProcess and postTemplateProcess
|
getBufferOutput | public boolean getBufferOutput()(Code) | | Allow customization of either (when true) to write result to response stream/writer
only when everything is ok (without exception) or otherwise. This is usefull
when using Freemarker's "rethrow" exception handler, where we don't want
partial of the page to be writen and then exception occurred and we have
freemarker's "rethrow" exception handler to take over but its too late since
part of the response has already been 'commited' to the stream/writer.
boolean |
getConfiguration | protected Configuration getConfiguration() throws TemplateException(Code) | | This method is called from
FreemarkerResult.doExecute(String,ActionInvocation) to obtain the
FreeMarker configuration object that this result will use for template loading. This is a
hook that allows you to custom-configure the configuration object in a subclass, or to fetch
it from an IoC container.
The default implementation obtains the configuration from the ConfigurationManager instance.
|
getContentType | public String getContentType()(Code) | | allow parameterization of the contentType
the default being text/html
|
getObjectWrapper | protected ObjectWrapper getObjectWrapper()(Code) | | This method is called from
FreemarkerResult.doExecute(String,ActionInvocation) to obtain the
FreeMarker object wrapper object that this result will use for adapting objects into template
models. This is a hook that allows you to custom-configure the wrapper object in a subclass.
The default implementation returns
Configuration.getObjectWrapper
|
getWriter | protected Writer getWriter() throws IOException(Code) | | The default writer writes directly to the response writer.
|
postTemplateProcess | protected void postTemplateProcess(Template template, TemplateModel data) throws IOException(Code) | | the default implementation of postTemplateProcess applies the contentType parameter
|
preTemplateProcess | protected boolean preTemplateProcess(Template template, TemplateModel model) throws IOException, TemplateException(Code) | | Called before the execution is passed to template.process().
This is a generic hook you might use in subclasses to perform a specific
action before the template is processed. By default does nothing.
A typical action to perform here is to inject application-specific
objects into the model root
true to process the template, false to suppress template processing. |
setBufferOutput | public void setBufferOutput(boolean bufferedOutput)(Code) | | |
setContentType | public void setContentType(String aContentType)(Code) | | |
|
|