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.
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitexecutepublic OnwardResolution(String path)
path - the path to which the resolution should navigatepublic OnwardResolution(Class<? extends ActionBean> beanType)
beanType - a Class that represents an ActionBeanpublic OnwardResolution(Class<? extends ActionBean> beanType, String event)
beanType - a Class that represents an ActionBeanevent - the String name of the event to trigger on navigationpublic String getEvent()
public boolean isEventSpecified()
public String getPath()
public void setPath(String path)
protected String getAnchor()
protected T setAnchor(String anchor)
public String toString()
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.
name - the name of the URL parametervalues - zero or more scalar values, or a single Collectionpublic 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 - a Map of parameters as described abovepublic 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.
@Deprecated public String getUrl()
getUrl(Locale).© Copyright 2005-2006, Stripes Development Team.