You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Description

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 Result Types using a name-value pair structure.

Result tags

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:

String SUCCESS = "success";
String NONE    = "none";
String ERROR   = "error";
String INPUT   = "input";
String LOGIN   = "login";

You can extend these as you see fit. Most of the time you will have either SUCCESS or ERROR, with SUCCESS moving on to the next page in your application;

<result name="success" type="dispatcher">
    <param name="location">/thank_you.jsp</param>
</result>

...and ERROR moving on to an error page, or the preceding page;

<result name="error" type="dispatcher">
    <param name="location">/error.jsp</param>
</result>

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:

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

or simplified

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

// TODO: merge contents, remove duplicated information

Results

<result name="missing-data" type="dispatcher">
    <param name="location">/form.jsp</param>
    <param name="parameterA">A</param>
    <param name="parameterB">B</param>
</result>

Result tags tell WebWork what to do next after the action has been called. The "name" attribute maps to the result code returned from the action execute() method. The "type" attribute indicates what result type class to use (see Result Types). The "param" elements allow you to pass parameters to
the view:

<result-types>
     ....
    <result-type name="header"                    
         class="com.opensymphony.webwork.dispatcher.HttpHeaderResult"/>
		
</result-types>

<result name="no-content" type="header">
    <param name="status">204</param>
    <param name="headers.customHeaderA">A</param>
    <param name="headers.customHeaderB">B</param>
</result>

There are a standard set of result codes built-in to WebWork, (in the Action interface) they include:

Action.SUCCESS = "success";
Action.NONE    = "none";
Action.ERROR   = "error";
Action.INPUT   = "input";
Action.LOGIN   = "login";

You can extend these result codes as you see fit (i.e "missing-data"). Most of the time you will have either SUCCESS or ERROR, with SUCCESS moving on to the next page in your application.

If you only need to specify the "location" parameter, you can use the short form:

<result name="missing-data" type="dispatcher">/form.jsp</result>

See webwork-default.xml or Result Types for standard result types.

  • No labels