Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.dispatcher
Class ServletActionRedirectResult

    java.lang.Object
      org.apache.struts2.dispatcher.StrutsResultSupport
          org.apache.struts2.dispatcher.ServletRedirectResult
              org.apache.struts2.dispatcher.ServletActionRedirectResult

All Implemented Interfaces:
  Result, ReflectionExceptionHandler, java.io.Serializable, StrutsStatics

    public class ServletActionRedirectResult

extends ServletRedirectResult
implements ReflectionExceptionHandler

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 struts.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. See examples below for an example of how request parameters could be passed in. This result type takes the following parameters:

- actionName (default) - the name of the action that will be redirect to
- namespace - used to determine which namespace the action is in that we're redirecting to . If namespace is null, this defaults to the current namespace
- supressEmptyParameters - optional boolean (defaults to false) that can prevent parameters with no values from being included in the redirect URL.

Example:

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

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

         <action name="error" class="...">
             <result>error.jsp</result>
         </action>
     </package>

     <package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters">
        <-- Pass parameters (reportType, width and height) -->
        <!--
        The redirectAction url generated will be :
        /genReport/generateReport.action?reportType=pie&width=100&height=100
        -->
        <action name="gatherReportInfo" class="...">
           <result name="showReportResult" type="redirectAction">
              <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>
              <param name="empty"></param>
              <param name="supressEmptyParameters">true</param>
           </result>
        </action>
     </package>

See Also:
  `ActionMapper`, Serialized Form

Field Summary
`protected java.lang.String` | `actionName`
`static java.lang.String` | `DEFAULT_PARAM` The default parameter
`protected java.lang.String` | `method`
`protected java.lang.String` | `namespace`

Fields inherited from class org.apache.struts2.dispatcher.ServletRedirectResult
`actionMapper, anchor, prependServletContext, requestParameters, statusCode, supressEmptyParameters`

Fields inherited from interface org.apache.struts2.StrutsStatics
`HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION, STRUTS_PORTLET_CONTEXT`

Constructor Summary
`ServletActionRedirectResult()`
`ServletActionRedirectResult(java.lang.String actionName)`
`ServletActionRedirectResult(java.lang.String actionName, java.lang.String method)`
`ServletActionRedirectResult(java.lang.String namespace, java.lang.String actionName, java.lang.String method)`
`ServletActionRedirectResult(java.lang.String namespace, java.lang.String actionName, java.lang.String method, java.lang.String anchor)`

Method Summary
`void` | `execute(ActionInvocation invocation)` Implementation of the `execute` method from the `Result` interface.
`protected java.util.List<java.lang.String>` | `getProhibitedResultParams()`
`void` | `setActionName(java.lang.String actionName)` Sets the action name
`void` | `setMethod(java.lang.String method)` Sets the method
`void` | `setNamespace(java.lang.String namespace)` Sets the namespace

Methods inherited from class org.apache.struts2.dispatcher.ServletRedirectResult
`addParameter, doExecute, handle, sendRedirect, setActionMapper, setAnchor, setPrependServletContext, setStatusCode, setSupressEmptyParameters`

Methods inherited from class org.apache.struts2.dispatcher.StrutsResultSupport
`conditionalParse, getLastFinalLocation, getLocation, setEncode, setLocation, setParse`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler
`handle`

Field Detail

### DEFAULT_PARAM

    public static final java.lang.String DEFAULT_PARAM

  The default parameter

  See Also:
    Constant Field Values

### actionName

    protected java.lang.String actionName

### namespace

    protected java.lang.String namespace

### method

    protected java.lang.String method

Constructor Detail

### ServletActionRedirectResult

    public ServletActionRedirectResult()

### ServletActionRedirectResult

    public ServletActionRedirectResult(java.lang.String actionName)

### ServletActionRedirectResult

    public ServletActionRedirectResult(java.lang.String actionName,
                                       java.lang.String method)

### ServletActionRedirectResult

    public ServletActionRedirectResult(java.lang.String namespace,
                                       java.lang.String actionName,
                                       java.lang.String method)

### ServletActionRedirectResult

    public ServletActionRedirectResult(java.lang.String namespace,
                                       java.lang.String actionName,
                                       java.lang.String method,
                                       java.lang.String anchor)

Method Detail

### execute

    public void execute(ActionInvocation invocation)
                 throws java.lang.Exception

  Description copied from class: `StrutsResultSupport`
  Implementation of the `execute` method from the `Result` interface. This will call the abstract method `StrutsResultSupport.doExecute(String, ActionInvocation)` after optionally evaluating the location as an OGNL evaluation.

  Specified by:
    `execute` in interface `Result`
  Overrides:
    `execute` in class `ServletRedirectResult`
  Parameters:
    `invocation` - the execution state of the action.
  Throws:
    `java.lang.Exception` - if an error occurs while executing the result.
  See Also:
    `Result.execute(com.opensymphony.xwork2.ActionInvocation)`

### setActionName

    public void setActionName(java.lang.String actionName)

  Sets the action name

  Parameters:
    `actionName` - The name

### setNamespace

    public void setNamespace(java.lang.String namespace)

  Sets the namespace

  Parameters:
    `namespace` - The namespace

### setMethod

    public void setMethod(java.lang.String method)

  Sets the method

  Parameters:
    `method` - The method

### getProhibitedResultParams

    protected java.util.List<java.lang.String> getProhibitedResultParams()

  Overrides:
    `getProhibitedResultParams` in class `ServletRedirectResult`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.