Versions Compared

Key

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

...

Code Block
xml
xml
<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 View Results). The "param" elements allow you to pass parameters to
the view:

Code Block
xml
xml

<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:

Code Block
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:

Code Block

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

See webwork-default.xml for standard result types.

Interceptors

Interceptors allow you to define code to be executed before and/or after the execution of an action. Interceptors can be a powerful tool when writing web applications. Some of the most common implementations of an Interceptor might be:

...