ActionRedirect (Struts 1.3.10 API)

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.struts.action
Class ActionRedirect

    java.lang.Object
      org.apache.struts.config.BaseConfig
          org.apache.struts.config.ForwardConfig
              org.apache.struts.action.ActionForward
                  org.apache.struts.action.ActionRedirect

All Implemented Interfaces:
  Serializable

    public class ActionRedirect

extends ActionForward

A subclass of `ActionForward` which is designed for use in redirecting requests, with support for adding parameters at runtime.
An `ForwardConfig` (or subclass) can be passed to the constructor to copy its configuration:

     public ActionForward execute(ActionMapping mapping,
                                  ActionForm form,
                                  HttpServletRequest request,
                                  HttpServletResponse response)
             throws Exception {
         ActionRedirect redirect =
                 new ActionRedirect(mapping.findForward("doRedirect"));
         redirect.addParameter("param1","value1");
         redirect.addParameter("param2","2");
         redirect.addParameter("param3","3.0");
         return redirect;
     }

Version:
  $Rev: 513602 $ $Date: 2007-03-01 20:50:23 -0600 (Thu, 01 Mar 2007) $
See Also:
  Serialized Form

Field Summary
`protected String` | `anchorValue` Holds the anchor value.
`protected static Log` | `LOG` Commons logging instance.
`protected Map` | `parameterValues` Holds the redirect parameters.

Fields inherited from class org.apache.struts.config.ForwardConfig
`catalog, command, extensionProcessed, inherit, module, name, path, redirect`

Fields inherited from class org.apache.struts.config.BaseConfig
`configured`

Constructor Summary
`ActionRedirect()` Construct a new instance with redirect set to true and initialize parameter lists.
`ActionRedirect(ForwardConfig baseConfig)` Construct a new instance with a `ForwardConfig` object to copy name, path, contextRelative, and arbitrary property values from.
`ActionRedirect(String path)` Construct a new instance with the specified path and initialize parameter lists.
`ActionRedirect(String name, String path, String module)` Construct a new instance with the specified values and initialize parameter lists.

Method Summary
`ActionRedirect` | `addParameter(String fieldName, Object valueObj)` Adds the object's toString() to the list of parameters if it's not null, or an empty string with the given fieldName if it is.
`String` | `getAnchorString()` Forms the string containing the parameters passed onto this object thru calls to addParameter().
`String` | `getOriginalPath()` Get the original path without the parameters added at runtime.
`String` | `getParameterString()` Forms the string containing the parameters passed onto this object thru calls to addParameter().
`String` | `getPath()` Get the path for this object, including any parameters that may have been added at runtime.
`ActionRedirect` | `setAnchor(String anchorValue)` Adds an anchor to the path.
`String` | `toString()` Return a string description of this object.

Methods inherited from class org.apache.struts.config.ForwardConfig
`checkCircularInheritance, getCatalog, getCommand, getExtends, getModule, getName, getRedirect, inheritFrom, isExtensionProcessed, processExtends, setCatalog, setCommand, setExtends, setModule, setName, setPath, setRedirect`

Methods inherited from class org.apache.struts.config.BaseConfig
`copyProperties, freeze, getProperties, getProperty, inheritProperties, setProperties, setProperty, throwIfConfigured`

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

Field Detail

### LOG

    protected static final Log LOG

  Commons logging instance.

### parameterValues

    protected Map parameterValues

  Holds the redirect parameters. Each entry is either a String or a String[] depending on whether it has one or more entries.

### anchorValue

    protected String anchorValue

  Holds the anchor value.

Constructor Detail

### ActionRedirect

    public ActionRedirect()

  Construct a new instance with redirect set to true and initialize parameter lists.

### ActionRedirect

    public ActionRedirect(String path)

  Construct a new instance with the specified path and initialize parameter lists.

  Parameters:
    `path` - Path for this instance

### ActionRedirect

    public ActionRedirect(String name,
                          String path,
                          String module)

  Construct a new instance with the specified values and initialize parameter lists.

  Parameters:
    `name` - Name of this instance
    `path` - Path for this instance
    `module` - Module prefix, if any

### ActionRedirect

    public ActionRedirect(ForwardConfig baseConfig)

  Construct a new instance with a `ForwardConfig` object to copy name, path, contextRelative, and arbitrary property values from.

  Parameters:
    `baseConfig` - the `ForwardConfig` to copy configuration values from

Method Detail

### addParameter

    public ActionRedirect addParameter(String fieldName,
                                       Object valueObj)

  Adds the object's toString() to the list of parameters if it's not null, or an empty string with the given fieldName if it is.

  Parameters:
    `fieldName` - the name to use for the parameter
    `valueObj` - the value for this parameter
  Returns:
    The ActionRedirect instance this method is called on

### setAnchor

    public ActionRedirect setAnchor(String anchorValue)

  Adds an anchor to the path. Technically, the anchor value is just stored for later and will be added to the path in getPath(). Note that this is a considerably simpler method than the addParmaeter method because aside from encoding the value, there isn't really anything to do. Passing in null is fine because that is the value that will be checked for later to determine whether to append an anchor to the path or not.

  Parameters:
    `anchorValue` - The anchor to append to the path
  Returns:
    The ActionRefirect instance this method is called on

### getOriginalPath

    public String getOriginalPath()

  Get the original path without the parameters added at runtime.

  Returns:
    the original path as configured.

### getPath

    public String getPath()

  Get the path for this object, including any parameters that may have been added at runtime.

  Overrides:
    `getPath` in class `ForwardConfig`
  Returns:
    The path for this object.

### getAnchorString

    public String getAnchorString()

  Forms the string containing the parameters passed onto this object thru calls to addParameter().

  Returns:
    a string which can be appended to the URLs. The return string includes a leading hash mark (#).

### getParameterString

    public String getParameterString()

  Forms the string containing the parameters passed onto this object thru calls to addParameter().

  Returns:
    a string which can be appended to the URLs. The return string does not include a leading question mark (?).

### toString

    public String toString()

  Return a string description of this object.

  Overrides:
    `toString` in class `ForwardConfig`
  Returns:
    a string containing the original path for this object and the parameters it currently holds

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-2008 Apache Software Foundation. All Rights Reserved.