public interface PortletParameters
PortletParameters
interface defines the API
for accessing the parameters that are set for the portlet or on a portlet URL.
Portlet parameters store state information that the portlet needs to render itself, generate content by serving resources, or make decisions when executing portlet actions. Conceptually the portlet parameters correspond to query string parameters that are stored in the URL used to access the portlet, although they are not required to actually be present on the URL as visible parameters.
Private parameters parameters are available exclusively to a single portlet. Public parameters can be shared between portlets.
The portlet parameters governing the request can be read during all portlet
execution phases through the PortletParameters
object available
from the portlet request. Portlet parameters
can be set for subsequent or future portlet execution phases through
the MutablePortletParameters
object available from the
portlet response object or from the portlet URL.
Different types of portlet parameters are distinguished according to their use.
Refer to RenderState.getRenderParameters()
,
MutableRenderState.getRenderParameters()
, and
RenderState.getRenderParameters()
.
Example: Render URLs with differing render parameters can be used to implement tabbed navigation within a portlet.
Refer to ResourceRequest.getResourceParameters()
and
ResourceURL.getResourceParameters()
.
Example: Portlets may require several different pieces of content to be served for the governing render state. Resource URLs with differing resource parameters can be used to determine which content is to be served for a specific request.
Refer to ActionRequest.getActionParameters()
and
ActionURL.getActionParameters()
.
Example: Portlets may render a number of buttons or links
for the governing render state.
Action URLs with differing action parameters can be used to
determine which action is to be executed for a specific request.
Example: Portlets may render forms that, when submitted, may cause
parameters to be added to the portlet action request.
During action request processing, these form parameters will be available as
action parameters.
MutablePortletParameters
Modifier and Type | Method and Description |
---|---|
MutablePortletParameters |
clone()
Returns a
MutablePortletParameters object encapsulating a copy of the same
parameters as the original object. |
Set<String> |
getNames()
Returns a
Set of String
objects containing the names of the parameters contained
in this object. |
String |
getValue(String name)
Returns the value of a parameter as a
String . |
String[] |
getValues(String name)
Returns an array of
String objects containing
all of the values the given parameter, or
null if the parameter does not exist. |
boolean |
isEmpty()
Returns a
true if no parameters have been set. |
int |
size()
Returns the number of parameters in this object.
|
String getValue(String name)
String
.
Note that null
is a valid parameter value.
To determine whether a
parameter is present, use the Set.contains(Object)
method on the set returned by getNames()
.
Only parameters targeted to the current portlet are accessible.
This method should only be used if the
parameter has only one value. If the parameter might have
more than one value, use getValues(java.lang.String)
.
If this method is used with a multivalued
parameter, the value returned is equal to the first value
in the array returned by getValues
.
name
- a String
specifying the
name of the parameterString
representing the
single value of the parameter, or null
.IllegalArgumentException
- if name is null
.getValues(java.lang.String)
,
getNames()
Set<String> getNames()
Set
of String
objects containing the names of the parameters contained
in this object.
Changing the Set
has no effect on the originating
PortletParameters object.
Only parameter names targeted to the current portlet are returned.
Set
of String
objects, each String
containing
the name of a parameter; or an
empty Set
if the
PortletParameters object has no parameters.String[] getValues(String name)
String
objects containing
all of the values the given parameter, or
null
if the parameter does not exist.
If the parameter has a single value, the array has a length of 1.
Note that individual parameter values in the returned array
may be null
.
name
- a String
containing the name of
the parameter the value of which is requestedString
objects
containing the parameter values, or null
if the parameter does not exist.IllegalArgumentException
- if name is null
.getValue(java.lang.String)
boolean isEmpty()
true
if no parameters have been set.
true
if the object contains no parameters.
false
otherwiseint size()
MutablePortletParameters clone()
MutablePortletParameters
object encapsulating a copy of the same
parameters as the original object.
Changing a mutable copy will not influence the source object.
Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.