com.opensymphony.webwork.dispatcher
Class ServletActionRedirectResult

java.lang.Object
  extended by com.opensymphony.webwork.dispatcher.WebWorkResultSupport
      extended by com.opensymphony.webwork.dispatcher.ServletRedirectResult
          extended by com.opensymphony.webwork.dispatcher.ServletActionRedirectResult
All Implemented Interfaces:
WebWorkStatics, Result, Serializable

public class ServletActionRedirectResult
extends ServletRedirectResult

This result uses the ActionMapper provided by the ActionMapperFactory to redirect the browser to a URL that invokes the specified action and (optional) namespace. This is better than the ServletRedirectResult because it does not require you to encode the URL patterns processed by the ActionMapper in to your xwork.xml configuration files. This means you can change your URL patterns at any point and your application will still work. It is strongly recommended that if you are redirecting to another action, you use this result rather than the standard redirect result.

To pass parameters, the <param> ... </param> tag. The following parameters will not be passable becuase they are part of the config param for this particular result.

See examples below for an example of how request parameters could be passed in. This result type takes the following parameters: Example:

 <package name="public" extends="webwork-default">
     <action name="login" class="...">
         <!-- Redirect to another namespace -->
         <result type="redirect-action">
             <param name="actionName">dashboard</param>
             <param name="namespace">/secure</param>
         </result>
     </action>
 </package>

 <package name="secure" extends="webwork-default" namespace="/secure">
     <-- Redirect to an action in the same namespace -->
     <action name="dashboard" class="...">
         <result>dashboard.jsp</result>
         <result name="error" type="redirect-action>error</result>
     </action>

     <action name="error" class="...">
         <result>error.jsp</result>
     </action>
 </package>
 
 <package name="passingRequestParameters" extends="webwork-default" namespace="/passingRequestParameters">
          <-- Pass parameters (reportType, width and height) -->
    <!-- 
    The redirect-action url generated will be : 
    /genReport/generateReport.action?reportType=pie&width=100&height=100
    -->
    <action name="gatherReportInfo" class="...">
       <result name="showReportResult" type="redirect-action">
        <param name="actionName">generateReport</param>
          <param name="namespace=">/genReport</param>
          <param name="reportType">pie</param>
          <param name="width">100</param>
          <param name="height">100</param>
       </result>
    </action>
 </package>
 
 

See Also:
ActionMapper, Serialized Form

Field Summary
protected  String actionName
           
static String DEFAULT_PARAM
           
protected  String method
           
protected  String namespace
           
protected  List prohibitedResultParam
           
 
Fields inherited from class com.opensymphony.webwork.dispatcher.ServletRedirectResult
prependServletContext
 
Fields inherited from class com.opensymphony.webwork.dispatcher.WebWorkResultSupport
encode, location, parse
 
Fields inherited from interface com.opensymphony.webwork.WebWorkStatics
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER
 
Constructor Summary
ServletActionRedirectResult()
           
 
Method Summary
 void execute(ActionInvocation invocation)
          Implementation of the execute method from the Result interface.
 void setActionName(String actionName)
           
 void setMethod(String method)
           
 void setNamespace(String namespace)
           
 
Methods inherited from class com.opensymphony.webwork.dispatcher.ServletRedirectResult
doExecute, setPrependServletContext
 
Methods inherited from class com.opensymphony.webwork.dispatcher.WebWorkResultSupport
conditionalParse, setEncode, setLocation, setParse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PARAM

public static final String DEFAULT_PARAM
See Also:
Constant Field Values

actionName

protected String actionName

namespace

protected String namespace

method

protected String method

prohibitedResultParam

protected List prohibitedResultParam
Constructor Detail

ServletActionRedirectResult

public ServletActionRedirectResult()
Method Detail

execute

public void execute(ActionInvocation invocation)
             throws Exception
Description copied from class: WebWorkResultSupport
Implementation of the execute method from the Result interface. This will call the abstract method WebWorkResultSupport.doExecute(String, ActionInvocation) after optionally evaluating the location as an OGNL evaluation.

Specified by:
execute in interface Result
Overrides:
execute in class WebWorkResultSupport
Parameters:
invocation - the execution state of the action.
Throws:
Exception - if an error occurs while executing the result.

setActionName

public void setActionName(String actionName)

setNamespace

public void setNamespace(String namespace)

setMethod

public void setMethod(String method)

WebWork Project Page