|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PortletPreferences
The 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:
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.
Method Summary | |
---|---|
java.util.Map<java.lang.String,java.lang.String[]> | getMap()
Returns a Map of the preferences. |
java.util.Enumeration<java.lang.String> | getNames()
Returns all of the keys that have an associated value, or an empty Enumeration if no keys are available. |
java.lang.String | getValue(java.lang.String key,
java.lang.String def)
Returns the first String value associated with the specified key of this preference. |
java.lang.String[] | getValues(java.lang.String key,
java.lang.String[] def)
Returns the String array value associated with the specified key in this preference. |
boolean | isReadOnly(java.lang.String key)
Returns true, if the value of this key is defined as read-only and thus cannot be modified by the user. |
void | reset(java.lang.String key)
Resets or removes the value associated with the specified key. |
void | setValue(java.lang.String key,
java.lang.String value)
Associates the specified String value with the specified key in this preference. |
void | setValues(java.lang.String key,
java.lang.String[] values)
Associates the specified String array value with the specified key in this preference. |
void | store()
Commits all changes made to the preferences via the set methods in the persistent store. |
Method Detail |
---|
boolean isReadOnly(java.lang.String key)
Modifiable preferences can be changed by the portlet in any standard portlet mode (EDIT, HELP, VIEW). Per default every preference is modifiable.
Read-only preferences cannot be changed by the portlet in any standard portlet mode, but inside of custom modes, like the CONFIG mode, it may be allowed changing them.
Preferences are read-only, if they are defined in the deployment descriptor with read-only set to true, or if the portlet container restricts write access.
Note that even if this call returns false and the preference key is modifiable in general it does not mean that it is modifiable in the scope of the current request, e.g. if this request is a render request.
java.lang.String getValue(java.lang.String key, java.lang.String def)
java.lang.String[] getValues(java.lang.String key, java.lang.String[] def)
Returns the specified default if there is no value associated with the key, or if the backing store is inaccessible. A null value is treated as a non-existent value.
If the implementation supports stored defaults and such a default exists and is accessible, it is used in favor of the specified default.
void setValue(java.lang.String key, java.lang.String value) throws ReadOnlyException
The key cannot be null, but null values for the value parameter are allowed.
If the same key contained already a String or String[] value it must be replaced by the new value.
void setValues(java.lang.String key, java.lang.String[] values) throws ReadOnlyException
The key cannot be null, but null values in the values parameter are allowed.
If the same key contained already a String or String[] value it must be replaced by the new value.
java.util.Enumeration<java.lang.String> getNames()
java.util.Map<java.lang.String,java.lang.String[]> getMap()
The values in the returned Map are from type String array (String[]).
If no preferences exist this method returns an empty Map.
void reset(java.lang.String key) throws ReadOnlyException
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.
void store() throws java.io.IOException, ValidatorException
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 store method are discarded when the portlet finishes the processAction method.
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 ValidatorException is thrown.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |