net.sourceforge.stripes.action
Class OnwardResolution<T extends OnwardResolution<T>>

java.lang.Object
  extended by net.sourceforge.stripes.action.OnwardResolution<T>
All Implemented Interfaces:
Resolution
Direct Known Subclasses:
ForwardResolution, RedirectResolution

public abstract class OnwardResolution<T extends OnwardResolution<T>>
extends Object
implements Resolution

Abstract class that provides a consistent API for all Resolutions that send the user onward to another view - either by forwarding, redirecting or some other mechanism. Provides methods for getting and setting the path that the user should be sent to next.

The rather odd looking generic declaration on this class is called a self-bounding generic type. The declaration allows methods in this class like addParameter(String, Object...) to return the appropriate type when accessed through subclasses. I.e. RedirectResolution.addParameter(String, Object...) will return a reference of type RedirectResolution instead of OnwardResolution.

Author:
Tim Fennell

Constructor Summary
OnwardResolution(Class<? extends ActionBean> beanType)
          Constructor that will extract the url binding for the ActionBean class supplied and use that as the path for the resolution.
OnwardResolution(Class<? extends ActionBean> beanType, String event)
          Constructor that will extract the url binding for the ActionBean class supplied and use that as the path for the resolution and adds a parameter to ensure that the specified event is invoked.
OnwardResolution(String path)
          Default constructor that takes the supplied path and stores it for use.
 
Method Summary
 T addParameter(String name, Object... values)
          Adds a request parameter with zero or more values to the URL.
 T addParameters(Map<String,? extends Object> parameters)
          Bulk adds one or more request parameters to the URL.
protected  String getAnchor()
          Get the name of the anchor to be appended to the URL.
 String getEvent()
          Get the event name that was specified in one of the constructor calls.
 Map<String,Object> getParameters()
          Provides access to the Map of parameters that has been accumulated so far for this resolution.
 String getPath()
          Accessor for the path that the user should be sent to.
 String getUrl()
          Deprecated. As of Stripes 1.5, this method has been replaced by getUrl(Locale).
 String getUrl(Locale locale)
          Constructs the URL for the resolution by taking the path and appending any parameters supplied.
 boolean isEventSpecified()
          Return true if an event name was specified when this instance was constructed.
protected  T setAnchor(String anchor)
          Set the name of the anchor to be appended to the URL.
 void setPath(String path)
          Setter for the path that the user should be sent to.
 String toString()
          Method that will work for this class and subclasses; returns a String containing the class name, and the path to which it will send the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sourceforge.stripes.action.Resolution
execute
 

Constructor Detail

OnwardResolution

public OnwardResolution(String path)
Default constructor that takes the supplied path and stores it for use.

Parameters:
path - the path to which the resolution should navigate

OnwardResolution

public OnwardResolution(Class<? extends ActionBean> beanType)
Constructor that will extract the url binding for the ActionBean class supplied and use that as the path for the resolution.

Parameters:
beanType - a Class that represents an ActionBean

OnwardResolution

public OnwardResolution(Class<? extends ActionBean> beanType,
                        String event)
Constructor that will extract the url binding for the ActionBean class supplied and use that as the path for the resolution and adds a parameter to ensure that the specified event is invoked.

Parameters:
beanType - a Class that represents an ActionBean
event - the String name of the event to trigger on navigation
Method Detail

getEvent

public String getEvent()
Get the event name that was specified in one of the constructor calls.


isEventSpecified

public boolean isEventSpecified()
Return true if an event name was specified when this instance was constructed.


getPath

public String getPath()
Accessor for the path that the user should be sent to.


setPath

public void setPath(String path)
Setter for the path that the user should be sent to.


getAnchor

protected String getAnchor()
Get the name of the anchor to be appended to the URL.


setAnchor

protected T setAnchor(String anchor)
Set the name of the anchor to be appended to the URL.


toString

public String toString()
Method that will work for this class and subclasses; returns a String containing the class name, and the path to which it will send the user.

Overrides:
toString in class Object

addParameter

public T addParameter(String name,
                      Object... values)

Adds a request parameter with zero or more values to the URL. Values may be supplied using varargs, or alternatively by suppling a single value parameter which is an instance of Collection.

Note that this method is additive. Therefore writing things like builder.addParameter("p", "one").addParameter("p", "two"); will add both p=one and p=two to the URL.

Parameters:
name - the name of the URL parameter
values - zero or more scalar values, or a single Collection
Returns:
this Resolution so that methods can be chained

addParameters

public T addParameters(Map<String,? extends Object> parameters)

Bulk adds one or more request parameters to the URL. Each entry in the Map represents a single named parameter, with the values being either a scalar value, an array or a Collection.

Note that this method is additive. If a parameter with name X has already been added and the map contains X as a key, the value(s) in the map will be added to the URL as well as the previously held values for X.

Parameters:
parameters - a Map of parameters as described above
Returns:
this Resolution so that methods can be chained

getParameters

public Map<String,Object> getParameters()

Provides access to the Map of parameters that has been accumulated so far for this resolution. The reference returned is to the internal parameters map! As such any changed made to the Map will be reflected in the Resolution, and any subsequent calls to addParameter(s) will be reflected in the Map.

Returns:
the Map of parameters for the resolution

getUrl

@Deprecated
public String getUrl()
Deprecated. As of Stripes 1.5, this method has been replaced by getUrl(Locale).

Constructs the URL for the resolution by taking the path and appending any parameters supplied.


getUrl

public String getUrl(Locale locale)
Constructs the URL for the resolution by taking the path and appending any parameters supplied.

Parameters:
locale - the locale to be used by Formatters when formatting parameters


© Copyright 2005-2006, Stripes Development Team.