org.apache.beehive.netui.pageflow
Class Forward

Object
  extended by ForwardConfig
      extended by ActionForward
          extended by Forward
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InterceptorForward

public class Forward
extends ActionForward

An object of this type is returned from an action methods in a PageFlowController to determine the next URI to be displayed. It is constructed on the name of a forward defined by the @jpf:forward tag, and resolves to the URI specified in that forward.

See Also:
Serialized Form

Field Summary
static int RETURN_TO_ACTION
          Deprecated. Use RETURN_TO_PREVIOUS_ACTION instead.
static int RETURN_TO_CURRENT_PAGE
           
static int RETURN_TO_NONE
           
static int RETURN_TO_PAGE
          Deprecated. Use RETURN_TO_CURRENT_PAGE or RETURN_TO_PREVIOUS_PAGE instead.
static int RETURN_TO_PREVIOUS_ACTION
           
static int RETURN_TO_PREVIOUS_PAGE
           
 
Fields inherited from class ForwardConfig
configured, contextRelative, name, path, redirect
 
Constructor Summary
protected Forward(ActionForward initFwd, ServletContext servletContext)
          Internal.
protected Forward(Forward init)
           
protected Forward(HttpServletRequest request)
           
  Forward(String forwardName)
          Constructor which accepts the name of a forward defined by the @jpf:forward tag.
  Forward(String forwardName, Object outputFormBean)
          Constructor which accepts the name of a forward defined by the @jpf:forward tag.
  Forward(String forwardName, String actionOutputName, Object actionOutputValue)
          Constructor which accepts the name of a forward defined by the @jpf:forward tag.
  Forward(URI path)
          Constructs a Forward that returns the given URI for getPath().
  Forward(URI path, boolean redirect)
          Constructs a Forward that returns the given URI for getPath().
  Forward(URL path)
          Constructs a Forward that returns the given URL for getPath().
 
Method Summary
 void addActionOutput(String name, Object value)
          Adds an action output that will be made available in the request, through PageFlowUtils.getActionOutput(java.lang.String, javax.servlet.ServletRequest).
 void addOutputForm(Object formBean)
          Add a form bean that will be made available in the request (or user session, as appropriate) if this Forward is returned by an action method in a PageFlowController.
 void addPageInput(String name, Object value)
          Deprecated. Use addActionOutput(java.lang.String, java.lang.Object) instead.
 void addQueryParam(String name)
          Add a query parameter with no value to the URI returned by getPath().
 void addQueryParam(String name, String value)
          Add a query parameter to the URI returned by getPath().
 boolean doesResolve()
          Tell whether getPath() will be successful, i.e., whether one of the following two conditions is met: the name around which this object was constructed resolves to a path defined by a @jpf:forward, or this object was constructed around an explicit path, by Forward(java.net.URI) or Forward(java.net.URL).
protected  ActionForward findForward(String forwardName)
          Resolves the forward with the given name, from the stored ActionMapping if possible, or from the stored alternate ModuleConfig as a last resort.
 boolean forwardsToPageFlow()
          Tell whether the URI returned by getPath() is for a page flow.
 Map getActionOutputs()
          Get all action outputs that have been set on this Forward.
 ActionForm[] getOutputForms()
          Get all form-beans attached to this forward through addOutputForm(java.lang.Object) or Forward(java.lang.String, java.lang.Object).
 Map getPageInputs()
          Deprecated. Use getActionOutputs() instead.
 String getPath()
          Get the URI path associated with this object.
 String getQueryString()
          Get the query string that will be appended to the URI returned by getPath().
 int getReturnToType()
          Get the type of return, if this is a return-to type.
 String getReturnToTypeAsString()
          Get the type of return as a String, if this is a return-to type.
 void initialize(ActionMapping mapping, FlowController flowController)
          Deprecated. Use initialize(org.apache.struts.action.ActionMapping, org.apache.beehive.netui.pageflow.FlowController, javax.servlet.http.HttpServletRequest) instead.
 void initialize(ActionMapping mapping, FlowController flowController, HttpServletRequest request)
          Set the current ActionMapping and associated FlowController.
 boolean isExternalRedirect()
           
 boolean isNestedReturn()
          Tell whether returning this forward from an action method will cause a return from a nested PageFlowController.
 boolean isRedirect()
          Tell whether the URI resolved by this Forward should be redirected to.
 boolean isReturnToAction()
          Tell whether returning this forward from an action method will cause the previous action to be re-run.
 boolean isReturnToPage()
          Tell whether returning this forward from an action method will cause a previous page to be displayed.
 void setExternalRedirect(boolean externalRedirect)
           
 void setPath(String path)
          Set the path to be returned by getPath().
 void setQueryString(String queryString)
          Set the query string that will be appended to the URI returned by getPath().
 void setRedirect(boolean redirect)
          Set whether the URI resolved by this Forward should be redirected to.
 
Methods inherited from class ForwardConfig
freeze, getContextRelative, getName, getRedirect, setContextRelative, setName, toString
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RETURN_TO_NONE

public static final int RETURN_TO_NONE
See Also:
Constant Field Values

RETURN_TO_CURRENT_PAGE

public static final int RETURN_TO_CURRENT_PAGE
See Also:
Constant Field Values

RETURN_TO_PREVIOUS_PAGE

public static final int RETURN_TO_PREVIOUS_PAGE
See Also:
Constant Field Values

RETURN_TO_PREVIOUS_ACTION

public static final int RETURN_TO_PREVIOUS_ACTION
See Also:
Constant Field Values

RETURN_TO_PAGE

public static final int RETURN_TO_PAGE
Deprecated. Use RETURN_TO_CURRENT_PAGE or RETURN_TO_PREVIOUS_PAGE instead.
See Also:
Constant Field Values

RETURN_TO_ACTION

public static final int RETURN_TO_ACTION
Deprecated. Use RETURN_TO_PREVIOUS_ACTION instead.
See Also:
Constant Field Values
Constructor Detail

Forward

protected Forward(Forward init)

Forward

protected Forward(HttpServletRequest request)

Forward

public Forward(String forwardName)
Constructor which accepts the name of a forward defined by the @jpf:forward tag. The values returned from getPath(), ForwardConfig.getRedirect() and ForwardConfig.contextRelative are resolved from this forward.

Parameters:
forwardName - the name of the forward (@jpf:forward) to resolve.

Forward

public Forward(String forwardName,
               Object outputFormBean)
Constructor which accepts the name of a forward defined by the @jpf:forward tag. The values returned from getPath(), ForwardConfig.getRedirect() and ForwardConfig.contextRelative are resolved from this forward. Also accepts a form bean to make available in the request (or user session, as appropriate).

Parameters:
forwardName - the name of the forward (@jpf:forward) to resolve.
outputFormBean - a form bean instance to make available in the request (or user session, as appropriate). See addOutputForm(java.lang.Object) for details about how this manifests itself.

Forward

public Forward(String forwardName,
               String actionOutputName,
               Object actionOutputValue)
Constructor which accepts the name of a forward defined by the @jpf:forward tag. The values returned from getPath(), ForwardConfig.getRedirect() and ForwardConfig.contextRelative are resolved from this forward. Also accepts a named action output to make available in the request, through PageFlowUtils.getActionOutput(java.lang.String, javax.servlet.ServletRequest)..

Parameters:
forwardName - the name of the forward (@jpf:forward) to resolve.
actionOutputName - the name of a action output to make available in the request.
actionOutputValue - the action output object to make available in the request.

Forward

public Forward(URI path)
Constructs a Forward that returns the given URI for getPath(). By default the Forward will cause server forward (not a browser redirect); to change this, use setRedirect(boolean).

Parameters:
path - the URI to return for getPath().

Forward

public Forward(URI path,
               boolean redirect)
Constructs a Forward that returns the given URI for getPath().

Parameters:
path - the URI to return for getPath().
redirect - set to true if this Forward should cause a browser redirect; false if it should cause a server forward.

Forward

public Forward(URL path)
Constructs a Forward that returns the given URL for getPath(). Because the URL path is absolute by nature, this Forward will cause a browser redirect.

Parameters:
path - the URL to return for getPath().

Forward

protected Forward(ActionForward initFwd,
                  ServletContext servletContext)
Internal. Initialize from an existing Struts ActionForward.

Method Detail

setRedirect

public void setRedirect(boolean redirect)
Set whether the URI resolved by this Forward should be redirected to.

Overrides:
setRedirect in class ForwardConfig
Parameters:
redirect - if true, the controller will send a browser redirect to the URI for this Forward; otherwise, it will do a server forward to the URI.

isRedirect

public boolean isRedirect()
Tell whether the URI resolved by this Forward should be redirected to.

Returns:
true if the controller will send a browser redirect to the URI for this Forward; false if it will do a server forward to the URI.

addOutputForm

public final void addOutputForm(Object formBean)
Add a form bean that will be made available in the request (or user session, as appropriate) if this Forward is returned by an action method in a PageFlowController. Specifically, each form bean is stored as a request attribute with a name determined by PageFlowUtils.getFormBeanName(org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest).

Parameters:
formBean - the form bean instance to add.

getOutputForms

public final ActionForm[] getOutputForms()
Get all form-beans attached to this forward through addOutputForm(java.lang.Object) or Forward(java.lang.String, java.lang.Object).

Returns:
an array of ActionForm instances that are attached to this forward.

doesResolve

public boolean doesResolve()
Tell whether getPath() will be successful, i.e., whether one of the following two conditions is met:

Returns:
true if this forward does resolve to a URI path.

findForward

protected ActionForward findForward(String forwardName)
Resolves the forward with the given name, from the stored ActionMapping if possible, or from the stored alternate ModuleConfig as a last resort.

Parameters:
forwardName - the name of the forward to resolve.
Returns:
the resolved ActionForward, or null if none is found.

initialize

public void initialize(ActionMapping mapping,
                       FlowController flowController)
Deprecated. Use initialize(org.apache.struts.action.ActionMapping, org.apache.beehive.netui.pageflow.FlowController, javax.servlet.http.HttpServletRequest) instead.

Set the current ActionMapping and associated FlowController. Normally, this method is called by the framework, but you can use it to initialize the Forward object in order to call getPath().

Parameters:
mapping - the current ActionMapping; this can be obtained from FlowController.getMapping().
flowController - the object in which to look for referenced return-form members.

initialize

public void initialize(ActionMapping mapping,
                       FlowController flowController,
                       HttpServletRequest request)
Set the current ActionMapping and associated FlowController. Normally, this method is called by the framework, but you can use it to initialize the Forward object in order to call getPath().

Parameters:
mapping - the current ActionMapping; this can be obtained from FlowController.getMapping().
flowController - the object in which to look for referenced return-form members.

setPath

public void setPath(String path)
Set the path to be returned by getPath(). This overrides any path or forward name set in a constructor.

Overrides:
setPath in class ForwardConfig
Parameters:
path - the URI to be returned by getPath().

getPath

public String getPath()
Get the URI path associated with this object. Resolve it from the name of a forward (@jpf:forward) if necessary.

Overrides:
getPath in class ForwardConfig
Returns:
a String that is the URI path.
See Also:
Forward(java.lang.String), Forward(java.lang.String, java.lang.Object), Forward(java.net.URI), Forward(java.net.URL), setPath(java.lang.String)

isNestedReturn

public boolean isNestedReturn()
Tell whether returning this forward from an action method will cause a return from a nested PageFlowController.

Returns:
true if this forward will cause a return from nesting.

isReturnToPage

public boolean isReturnToPage()
Tell whether returning this forward from an action method will cause a previous page to be displayed.

Returns:
true if returning this forward from an action method will cause a previous page to be displayed.

isReturnToAction

public boolean isReturnToAction()
Tell whether returning this forward from an action method will cause the previous action to be re-run.

Returns:
true if returning this forward from an action method will cause the previous action to be re-run, i.e., whether the URI returned by getPath() will end in "previous-action-name.do".

isExternalRedirect

public boolean isExternalRedirect()

setExternalRedirect

public void setExternalRedirect(boolean externalRedirect)

forwardsToPageFlow

public boolean forwardsToPageFlow()
Tell whether the URI returned by getPath() is for a page flow.

Returns:
true if the URI returned by getPath() is for a page flow, i.e., if it ends in ".jpf".

setQueryString

public void setQueryString(String queryString)
Set the query string that will be appended to the URI returned by getPath().

Parameters:
queryString - the query string that will be appended to the URI. If this string does not start with '?', then this character will be prepended; if the string is null, the query string will be removed.

getQueryString

public String getQueryString()
Get the query string that will be appended to the URI returned by getPath().

Returns:
the query string that will be appended to the URI, or null if there is no query string.

addQueryParam

public void addQueryParam(String name,
                          String value)
Add a query parameter to the URI returned by getPath().

Parameters:
name - the name of the query parameter.
value - the value of the query parameter, or null if there is no value.

addQueryParam

public final void addQueryParam(String name)
Add a query parameter with no value to the URI returned by getPath().

Parameters:
name - the name of the query parameter.

addPageInput

public void addPageInput(String name,
                         Object value)
Deprecated. Use addActionOutput(java.lang.String, java.lang.Object) instead.

Adds an action output that will be made available in the request, through PageFlowUtils.getActionOutput(java.lang.String, javax.servlet.ServletRequest).

Parameters:
name - the name of the action output.
value - the action output value.

addActionOutput

public void addActionOutput(String name,
                            Object value)
Adds an action output that will be made available in the request, through PageFlowUtils.getActionOutput(java.lang.String, javax.servlet.ServletRequest).

Parameters:
name - the name of the action output.
value - the action output value.

getPageInputs

public Map getPageInputs()
Deprecated. Use getActionOutputs() instead.

Get all action outputs that have been set on this Forward.

Returns:
a Map of name/value pairs representing all action outputs.
See Also:
addActionOutput(java.lang.String, java.lang.Object)

getActionOutputs

public Map getActionOutputs()
Get all action outputs that have been set on this Forward.

Returns:
a Map of name/value pairs representing all action outputs.
See Also:
addActionOutput(java.lang.String, java.lang.Object)

getReturnToType

public int getReturnToType()
Get the type of return, if this is a return-to type.

Returns:
one of the following values: RETURN_TO_CURRENT_PAGE, RETURN_TO_PREVIOUS_PAGE, RETURN_TO_PAGE, RETURN_TO_PREVIOUS_ACTION, RETURN_TO_ACTION, or RETURN_TO_NONE if this Forward is not a return-to type.
See Also:
isReturnToAction(), isReturnToPage()

getReturnToTypeAsString

public String getReturnToTypeAsString()
Get the type of return as a String, if this is a return-to type.

Returns:
one of the following values: currentPage, previousPage, page, (deprecated), previousAction, action (deprecated), or null if this is not a return-to type.
See Also:
isReturnToAction(), isReturnToPage()