Overview
Results of an Action are used in Webwork to map to a view implementation(ex. jsp, vm, html) or another action. Keep in mind though, 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 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 execution results, whether that be displaying a webpage, generating an email, sending a JMS message, etc.
Result types define classes and map them to names to be referred in the action configuration results. This serves as a shorthand name-value pair for these classes.
Code Block |
---|
<!-- parts of xwork.xml --> .... <result-types> <result-type name="dispatcher" class="com.opensymphony.webwork.dispatcher.ServletDispatcherResult" default="true"/> <result-type name="redirect" class="com.opensymphony.webwork.dispatcher.ServletRedirectResult"/> <result-type name="velocity" class="com.opensymphony.webwork.dispatcher.VelocityResult"/> <result-type name="chain" class="com.opensymphony.xwork.ActionChainResult"/> <result-type name="xslt" class="com.opensymphony.webwork.views.xslt.XSLTResult"/> <result-type name="jasper" class="com.opensymphony.webwork.views.jasperreports.JasperReportsResult"/> <result-type name="freemarker" class="com.opensymphony.webwork.views.freemarker.FreemarkerResult"/> </result-types> .... <!-- this action uses the result type dispatcher which is defined above --> <action name="bar" class="myPackage.barAction"> <result name="success" type="dispatcher"> <param name="location">foo.jsp</param> </result> <result name="error" type="dispatcher"> <param name="location">error.jsp</param> </result> </action> .... |
Result Types
Webwork provides several implementations of the com.opensymphony.xwork.Result
interface to make web-based interactions with your actions simple. These result types include:
...
Results are specified in a xwork xml config file(xwork.xml) nested inside <action>. The If the location
param is the default parameter, meaning you can specify the location two waysthe only param being specified in the result tag, you can simplify it as follows:
Code Block |
---|
<action name="bar" class="myPackage.barAction"> <result name="success" type="dispatcher"> <param name="location">foo.jsp</param> </result> </action> |
or simplified
Code Block |
---|
<action name="bar" class="myPackage.barAction"> <result name="success" type="dispatcher">foo.jsp</result> </action> |
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. See For more information on result tags and global-results, see Results and global-results
Dispatcher
Anchor | ||||
---|---|---|---|---|
|
...