public abstract class OnwardResolution<T extends OnwardResolution<T>> extends java.lang.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(java.lang.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(java.lang.Class<? extends ActionBean> beanType,
java.lang.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(java.lang.String path)
Default constructor that takes the supplied path and stores it for use.
|
Modifier and Type | Method and Description |
---|---|
T |
addParameter(java.lang.String name,
java.lang.Object... values)
Adds a request parameter with zero or more values to the URL.
|
T |
addParameters(java.util.Map<java.lang.String,? extends java.lang.Object> parameters)
Bulk adds one or more request parameters to the URL.
|
protected java.lang.String |
getAnchor()
Get the name of the anchor to be appended to the URL.
|
java.util.Map<java.lang.String,java.lang.Object> |
getParameters()
Provides access to the Map of parameters that has been accumulated so far
for this resolution.
|
java.lang.String |
getPath()
Accessor for the path that the user should be sent to.
|
java.lang.String |
getUrl()
Deprecated.
As of Stripes 1.5, this method has been replaced by
getUrl(Locale) . |
java.lang.String |
getUrl(java.util.Locale locale)
Constructs the URL for the resolution by taking the path and appending any parameters
supplied.
|
protected T |
setAnchor(java.lang.String anchor)
Set the name of the anchor to be appended to the URL.
|
void |
setPath(java.lang.String path)
Setter for the path that the user should be sent to.
|
java.lang.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, wait
execute
public OnwardResolution(java.lang.String path)
path
- the path to which the resolution should navigatepublic OnwardResolution(java.lang.Class<? extends ActionBean> beanType)
beanType
- a Class that represents an ActionBeanpublic OnwardResolution(java.lang.Class<? extends ActionBean> beanType, java.lang.String event)
beanType
- a Class that represents an ActionBeanevent
- the String name of the event to trigger on navigationpublic java.lang.String getPath()
public void setPath(java.lang.String path)
protected java.lang.String getAnchor()
protected T setAnchor(java.lang.String anchor)
public java.lang.String toString()
toString
in class java.lang.Object
public T addParameter(java.lang.String name, java.lang.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(java.util.Map<java.lang.String,? extends java.lang.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 java.util.Map<java.lang.String,java.lang.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 java.lang.String getUrl()
getUrl(Locale)
.public java.lang.String getUrl(java.util.Locale locale)
locale
- the locale to be used by Formatter
s when formatting parameters? Copyright 2005-2006, Stripes Development Team.