PortletPreferences interface allows the portlet to store
configuration data. It is not the
purpose of this interface to replace general purpose databases.
There are two different types of preferences:
EDIT, HELP, VIEW).
Per default every preference is modifiable.
read-only set to true,
or if the portlet container restricts write access.
Changes are persisted when the store method is called. The store method
can only be invoked within the scope of a processAction call.
Changes that are not persisted are discarded when the
processAction or render method ends.
| Modifier and Type | Method and Description |
|---|---|
| public Map | Returns: an immutableMap containing preference names as
keys and preference values as map values, or an empty Map
if no preference exist. The keys in the preference
map are of type String. The values in the preference map are of type
String array (String[]).Returns a |
| public Enumeration | Returns: an Enumeration of the keys that have an associated value, or an emptyEnumeration if no keys are
available.Returns all of the keys that have an associated value,
or an empty |
| public String | Returns: the value associated withkey, or def
if no value is associated with key, or the backing
store is inaccessible.key for which the associated value is to be returned key, String the value to be returned in the event that there is no
value available associated with this def)key.Returns the first String value associated with the specified key of this preference. |
| public String[] | Returns: the String array value associated withkey, or def if the
associated value does not exist.key for which associated value is to be returned. key, String[] the value to be returned in the event that this
preference node has no value associated with def)key
or the associated value cannot be interpreted as a String array,
or the backing store is inaccessible.Returns the String array value associated with the specified key in this preference. |
| public boolean | Returns: false, if the value of this key can be changed, or if the key is not knownReturns true, if the value of this key is defined as read-only and thus cannot be modified by the user. |
| public void | |
| public void | |
| public void | |
| public void |
| getMap | back to summary |
|---|---|
| public Map Returns a
The values in the returned
If no preferences exist this method returns an empty | |
| getNames | back to summary |
|---|---|
| public Enumeration Returns all of the keys that have an associated value,
or an empty
| |
| getValue | back to summary |
|---|---|
| public String getValue(String key, String def) Returns the first String value associated with the specified key of this preference.
If there is one or more preference values associated with the given key
it returns the first associated value.
If there are no preference values associated with the given key, or the
backing preference database is unavailable, it returns the given
default value.
A
| |
| getValues | back to summary |
|---|---|
| public String[] getValues(String key, String[] def) Returns the String array value associated with the specified key in this preference. Returns the specified default if there is no value
associated with the key, or if the backing store is inaccessible.
A If the implementation supports stored defaults and such a default exists and is accessible, it is used in favor of the specified default.
| |
| isReadOnly | back to summary |
|---|---|
| public boolean isReadOnly(String key) Returns true, if the value of this key is defined as read-only and thus cannot be modified by the user.
Modifiable preferences can be changed by the
portlet in any standard portlet mode (
Read-only preferences cannot be changed by the
portlet in any standard portlet mode, but inside of custom modes,
like the
Preferences are read-only, if they are defined in the
deployment descriptor with
Note that even if this call returns
| |
| reset | back to summary |
|---|---|
| public void reset(String key) throws ReadOnlyException Resets or removes the value associated with the specified key. If this implementation supports stored defaults, and there is such a default for the specified preference, the given key will be reset to the stored default. If there is no default available the key will be removed.
| |
| setValue | back to summary |
|---|---|
| public void setValue(String key, String value) throws ReadOnlyException Associates the specified String value with the specified key in this preference.
The key cannot be
If the same key contained already a
| |
| setValues | back to summary |
|---|---|
| public void setValues(String key, String... values) throws ReadOnlyException Sets a multi-valued String preference for the specified key.
The key cannot be
If the same key contained already a
| |
| store | back to summary |
|---|---|
| public void store() throws IOException, ValidatorException Commits all changes made to the preferences via the
If this call returns successful, all changes are made persistent. If this call fails, no changes are made in the persistent store. This call is an atomic operation regardless of how many preference attributes have been modified.
All changes made to preferences not followed by a call
to the
If a validator is defined for this preferences in the
deployment descriptor, this validator is called before
the actual store is performed to check whether the given
preferences are valid. If this check fails a
| |