Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Webwork provides several implementations of the com.opensymphony.xwork.Result interface to make web-based interactions with your actions simple. These result types include:

Result Type

name

class

#Dispatcher

dispatcher

com.opensymphony.webwork.dispatcher.ServletDispatcherResult

#Redirect

redirect

com.opensymphony.webwork.dispatcher.ServletRedirectResult

#Action Chaining

chain

com.opensymphony.xwork.ActionChainResult

#Velocity

velocity

com.opensymphony.webwork.dispatcher.VelocityResult

#FreeMarker

freemarker

com.opensymphony.webwork.views.freemarker.FreemarkerResult

#JasperReports

jasper

com.opensymphony.webwork.views.jasperreports.JasperReportsResult

#XML/XSL

xslt

com.opensymphony.webwork.views.xslt.XSLTResult

...

Code Block
<action name="bar" class="myPackage.barAction">
  <result name="success" type="dispatcher">foo.jsp</result>
</action>


Dispatcher
Anchor
Dispatcher
Dispatcher


Includes or forwards a view (usually a jsp)

...

Code Block
<result name="success" type="dispatcher">
    <param name="location">foo.jsp</param>
</result>


Redirect
Anchor
Redirect
Redirect


The response is told to redirect the browser to the specified location. The consequence of doing this means that the action that was just executed is lost or no longer available. This is because actions are built on a single-thread model.
NOTE: You may want to set the parse attribute to false so the location is not parsed for Ognl expressions.

...

Code Block
<result name="success" type="redirect">
    <param name="location">foo.jsp</param>
    <param name="parse">false</param>
</result>


Action Chaining
Anchor
Action Chaining
Action Chaining


A special kind of view that invokes GenericDispatch (using the previously existing ActionContext) and executes another action. This is useful if you need to execute one action immediately after another.

...

Code Block
<action name="bar" class="myPackage.barAction">
    ...
</action>


Velocity
Anchor
Velocity
Velocity


This result mocks a JSP execution environment and then displays a Velocity template that will be streamed directly to the servlet output.

...

Code Block
<result name="success" type="velocity">
    <param name="location">foo.vm</param>
</result>


FreeMarker
Anchor
FreeMarker
FreeMarker


Parameters

Required

Description

location

yes

the location to go to after execution

parse

no

true by default. If set to false, the location param will not be parsed for Ognl expressions

contentType

no

defaults to "text/html" unless specified

Code Block
<result name="success" type="freemarker">foo.ftl</result>


JasperReports
Anchor
JasperReports
JasperReports


Generates a JasperReports report using the specified format or PDF if no format is specified.

...

Code Block
<result name="success" type="jasper">
    <param name="location">foo.jasper</param>
    <param name="dataSource">mySource</param>
</result>


XML/XSL
Anchor
XML/XSL
XML/XSL


Interfaces with xml transformations.

...