Source

webwork / docs / wikidocs / Results.html

Full commit
<html>
    <head>
        <title>WebWork 2 : Results</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            WebWork 2 : Results
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Jun 16, 2004 by <font color="#0050B2">casey</font>.
				    </div>

				    <p class="paragraph"><h2 style="margin: 4px 0px 4px 0px;" class="heading2"><a name="Results-Overview"> Overview</a></h2></p>Results are string constants that Actions return to indicate the status of an Action execution. A standard set of Results are defined by default: error, input, login, none and success. Developers are, of course, free to create their own Results to indicate more application specific cases.  Results are mapped to defined <a href="Result Types.html" title="Result Types">Result Types</a> using a name-value pair structure.
<ul class="star">
<li> <a href="Global results.html" title="Global results">Global results</a></li>
<li> <a href="Default results.html" title="Default results">Default results</a></li>
</ul>
<h3 class="heading3"><a name="Results-Resulttags"> Result tags</a></h3><p class="paragraph">Result tags tell WebWork what to do next after the action has been called. There are a standard set of result codes built-in to WebWork, (in the Action interface) they include:
<div class="code"><div class="codeContent">
<pre><span class="java&#45;object">String</span> SUCCESS = <span class="java&#45;quote">&quot;success&quot;</span>;&#10;<span class="java&#45;object">String</span> NONE    = <span class="java&#45;quote">&quot;none&quot;</span>;&#10;<span class="java&#45;object">String</span> ERROR   = <span class="java&#45;quote">&quot;error&quot;</span>;&#10;<span class="java&#45;object">String</span> INPUT   = <span class="java&#45;quote">&quot;input&quot;</span>;&#10;<span class="java&#45;object">String</span> LOGIN   = <span class="java&#45;quote">&quot;login&quot;</span>;</pre>
</div></div></p>You can extend these as you see fit. Most of the time you will have either <b class="strong">SUCCESS</b> or <b class="strong">ERROR</b>, with <b class="strong">SUCCESS</b> moving on to the next page in your application;
<div class="code"><div class="codeContent">
<pre><span class="xml&#45;tag">&lt;result name=<span class="xml&#45;quote">&quot;success&quot;</span> type=<span class="xml&#45;quote">&quot;dispatcher&quot;</span>&gt;</span>&#10;    <span class="xml&#45;tag">&lt;param name=<span class="xml&#45;quote">&quot;location&quot;</span>&gt;</span>/thank&#95;you.jsp<span class="xml&#45;tag">&lt;/param&gt;</span>&#10;<span class="xml&#45;tag">&lt;/result&gt;</span></pre>
</div></div><p class="paragraph">…and <b class="strong">ERROR</b> moving on to an error page, or the preceding page;
<div class="code"><div class="codeContent">
<pre><span class="xml&#45;tag">&lt;result name=<span class="xml&#45;quote">&quot;error&quot;</span> type=<span class="xml&#45;quote">&quot;dispatcher&quot;</span>&gt;</span>&#10;    <span class="xml&#45;tag">&lt;param name=<span class="xml&#45;quote">&quot;location&quot;</span>&gt;</span>/error.jsp<span class="xml&#45;tag">&lt;/param&gt;</span>&#10;<span class="xml&#45;tag">&lt;/result&gt;</span></pre>
</div></div></p>Results are specified in a xwork xml config file(xwork.xml) nested inside &lt;action&gt;.  If the <tt class="monospaced">location</tt> param is the only param being specified in the result tag, you can simplify it as follows:<br/>

<div class="code"><div class="codeContent">
<pre>&lt;action name=<span class="java&#45;quote">&quot;bar&quot;</span> class=<span class="java&#45;quote">&quot;myPackage.barAction&quot;</span>&gt;&#10;  &lt;result name=<span class="java&#45;quote">&quot;success&quot;</span> type=<span class="java&#45;quote">&quot;dispatcher&quot;</span>&gt;&#10;    &lt;param name=<span class="java&#45;quote">&quot;location&quot;</span>&gt;foo.jsp&lt;/param&gt;&#10;  &lt;/result&gt;&#10;&lt;/action&gt;</pre>
</div></div><br/>
or simplified
<div class="code"><div class="codeContent">
<pre>&lt;action name=<span class="java&#45;quote">&quot;bar&quot;</span> class=<span class="java&#45;quote">&quot;myPackage.barAction&quot;</span>&gt;&#10;  &lt;result name=<span class="java&#45;quote">&quot;success&quot;</span> type=<span class="java&#45;quote">&quot;dispatcher&quot;</span>&gt;foo.jsp&lt;/result&gt;&#10;&lt;/action&gt;</pre>
</div></div><br/>



				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="border/border_bottom.gif"><img src="border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Oct 15, 2004 20:55</font></td>
		    </tr>
	    </table>
    </body>
</html>