|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.webwork.dispatcher.WebWorkResultSupport
com.opensymphony.webwork.views.freemarker.FreemarkerResult
public class FreemarkerResult
Renders a view using the Freemarker template engine. Alternatively, the
dispatcher
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
/WEB-INF/views/home.ftl
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.
<!-- START SNIPPET: example --> <result name="success" type="freemarker">foo.ftl</result> <!-- END SNIPPET: example -->
Field Summary | |
---|---|
protected boolean |
bufferOutput
|
protected freemarker.template.Configuration |
configuration
|
protected ActionInvocation |
invocation
|
protected String |
location
|
protected freemarker.template.ObjectWrapper |
wrapper
|
Fields inherited from class com.opensymphony.webwork.dispatcher.WebWorkResultSupport |
---|
DEFAULT_PARAM, encode, parse |
Fields inherited from interface com.opensymphony.webwork.WebWorkStatics |
---|
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER |
Constructor Summary | |
---|---|
FreemarkerResult()
|
Method Summary | |
---|---|
protected freemarker.template.TemplateModel |
createModel()
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 |
protected Locale |
deduceLocale()
Returns the locale used for the Configuration.getTemplate(String, Locale) call. |
void |
doExecute(String location,
ActionInvocation invocation)
Execute this result, using the specified template location. |
boolean |
getBufferOutput()
Allow customization of either (when true) to write result to response stream/writer only when everything is ok (without exception) or otherwise. |
protected freemarker.template.Configuration |
getConfiguration()
This method is called from doExecute(String, ActionInvocation) to obtain the
FreeMarker configuration object that this result will use for template loading. |
String |
getContentType()
allow parameterization of the contentType the default being text/html |
protected freemarker.template.ObjectWrapper |
getObjectWrapper()
This method is called from doExecute(String, ActionInvocation) to obtain the
FreeMarker object wrapper object that this result will use for adapting objects into template
models. |
protected Writer |
getWriter()
The default writer writes directly to the response writer. |
protected void |
postTemplateProcess(freemarker.template.Template template,
freemarker.template.TemplateModel data)
the default implementation of postTemplateProcess applies the contentType parameter |
protected boolean |
preTemplateProcess(freemarker.template.Template template,
freemarker.template.TemplateModel model)
Called before the execution is passed to template.process(). |
void |
setBufferOutput(boolean bufferedOutput)
|
void |
setContentType(String aContentType)
|
Methods inherited from class com.opensymphony.webwork.dispatcher.WebWorkResultSupport |
---|
conditionalParse, execute, setEncode, setLocation, setParse |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ActionInvocation invocation
protected freemarker.template.Configuration configuration
protected freemarker.template.ObjectWrapper wrapper
protected boolean bufferOutput
protected String location
Constructor Detail |
---|
public FreemarkerResult()
Method Detail |
---|
public void setContentType(String aContentType)
public String getContentType()
public void setBufferOutput(boolean bufferedOutput)
public boolean getBufferOutput()
public void doExecute(String location, ActionInvocation invocation) throws IOException, freemarker.template.TemplateException
doExecute
in class WebWorkResultSupport
location
- the location (jsp page, action, etc) to go to.invocation
- the execution state of the action.
IOException
freemarker.template.TemplateException
protected freemarker.template.Configuration getConfiguration() throws freemarker.template.TemplateException
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.
freemarker.template.TemplateException
protected freemarker.template.ObjectWrapper getObjectWrapper()
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 Configurable.getObjectWrapper()
protected Writer getWriter() throws IOException
IOException
protected freemarker.template.TemplateModel createModel() throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException
protected Locale deduceLocale()
Configuration.getTemplate(String, Locale)
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,
protected void postTemplateProcess(freemarker.template.Template template, freemarker.template.TemplateModel data) throws IOException
IOException
protected boolean preTemplateProcess(freemarker.template.Template template, freemarker.template.TemplateModel model) throws IOException, freemarker.template.TemplateException
IOException
freemarker.template.TemplateException
|
WebWork Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |