...
Result Types are classes that determine what happens after an Action executes and a Result is returned. Developers are free to create their own Result Types according to the needs of their application or environment. In WebWork 2 the framework, for example, Servlet and Velocity Result Types have been created to handle rendering views in web applications.
Note: All built in webwork result types implement the com.opensymphony.xwork.Result
interface, which represents a generic interface for all action Action execution results, whether that be displaying a webpage, generating an email, sending a JMS message, etcand so forth.
Result types Types define classes and map them to names to be referred in the action Action configuration results. This serves as a shorthand name-value pair for these classes.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<include file="webwork-default.xml"/> <package name="myPackage" extends="default"> <action name="bar" class="myPackage.barAction"> <!-- default result type is "dispatcher" --> <!-- default result name is "success" --> <result>foo.jsp</result> <result name="error">error.jsp</result> </result> </action> </package> |
Result Types
Webwork The framework provides several implementations of the com.opensymphony.xwork.Result
interface to make web-based interactions with your actions simple. These result types include:
...
Used for Action Chaining | |
...
Used for JSP integration | |
...
Used for FreeMarker integration | |
...
Used to control special HTTP behaviors | |
...
Used for JasperReports integration | |
...
Used to redirect to another URL | |
...
Used to redirect to another |
...
Action |
...
Used to stream an InputStream back to the browser (usually for file downloads) | |
...
Used for Velocity integration | |
...
Used for XML/XSLT integration | |
...
Used to display the raw content of a particular page ( |
...
i.e jsp, |
...
HTML) |
Results are specified in a xwork xml config file(xwork.xml) nested inside <action>. If the location
param is the only param being specified in the result tag, you can simplify it as follows:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<action name="bar" class="myPackage.barAction"> <result>foo.jsp</result> </action> |
NOTE Note: The Parse attribute enables the location element to be parsed for expressions. An example of how this could be useful:
Code Block | ||||
---|---|---|---|---|
| ||||
<result name="success" type="redirect">/displayCart.action?userId=${userId}</result> |
NOTE Note: You can also specify global-results to use with multiple actions. This can save time from having to add the same result to many different actions.
For more information on result tags and global-results, see Result Configuration section.