Versions Compared

Key

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

A result is a piece of code that is executed after your action has already completed and returned a value such as success or error. But webwork WebWork comes with most of the result you'll need, for example: such as "servlet dispatcher," used for JSPs, and Velocity as well as alternative results such as FreeMarker and Jasper Reports (in PDF, XML, and HTML).

Code Block
<action name="form03" class="lessons.Form03Action">
      <result name="success" type="dispatcher">page03-success.jsp</result>
      <result name="error" type="dispatcher">page03-error.jsp</result>
</action>

 

As you can see, that result configuration is made up of two parts: result mappings, which you've already seen associated with an action mapping, and result types.

Configuring result types

...

Code Block
<xwork>
   <include name="webwork-default.xml"/>
   <package name="default" extends="webwork-default">

      <result-types>
        <result-type name="dispatcher" class="..." default="true"/>
        <result-type name="redirect" class="..."/>
      </result-types>

      <default-interceptor-ref name="defaultStack"/>
 
      <action name="login"
           class="org.hibernate.auction.web.actions.users.Login">
        <result name="input">login.jsp</result>
        <result name="success"
           type="redirect">/secure/dashboard.action</result>
     </action>
   </package>
</xwork>

 

Reducing configuration duplication with global result mappings

...

Code Block
<package name="default" extends="webwork-default">
   <global-results>
      <result name="login"
         type="redirect">/login!default.action</result>
      <result name="unauthorized">/unauthorized.jsp</result>
   </global-results>
   <!-- other package declarations -->
</package>

 

Note
titleBe Careful

Because global reseults are searched after local results, you can override any global result mapping by creating a local result mapping for a specific action. Recall that results can point to locations using relative or absolute paths. Because you may not know the context in which they're being invoked, it's best to use absolute paths for global results.