class ComponentStateHelper extends java.lang.Object implements StateHelper, TransientStateHelper
| Modifier and Type | Field and Description |
|---|---|
private UIComponent |
component |
private java.util.Map<java.io.Serializable,java.lang.Object> |
defaultMap |
private java.util.Map<java.io.Serializable,java.lang.Object> |
deltaMap |
private boolean |
isTransient |
private java.util.Map<java.lang.Object,java.lang.Object> |
transientState |
| Constructor and Description |
|---|
ComponentStateHelper(UIComponent component) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.io.Serializable key,
java.lang.Object value)
Store the specified
|
java.lang.Object |
eval(java.io.Serializable key)
Attempts to find a value associated with the specified key, using the value expression collection from the component if no such value is found. |
java.lang.Object |
eval(java.io.Serializable key,
java.lang.Object defaultValue)
Performs the same logic as |
java.lang.Object |
get(java.io.Serializable key)
Get the object from the main-map.
|
java.lang.Object |
getTransient(java.lang.Object key)
Return the value currently
associated with the specified |
java.lang.Object |
getTransient(java.lang.Object key,
java.lang.Object defaultValue)
Performs the same logic as |
boolean |
isTransient()
If true, the Object implementing this interface must not
participate in state saving or restoring.
|
java.lang.Object |
put(java.io.Serializable key,
java.lang.Object value)
Put the object in the main-map
and/or the delta-map, if necessary.
|
java.lang.Object |
put(java.io.Serializable key,
java.lang.String mapKey,
java.lang.Object value)
Store the specified
|
java.lang.Object |
putTransient(java.lang.Object key,
java.lang.Object value)
Return the previously stored value and store the specified key/value pair. |
java.lang.Object |
remove(java.io.Serializable key)
We need to remove from both
maps, if we do remove an existing key.
|
java.lang.Object |
remove(java.io.Serializable key,
java.lang.Object valueOrKey)
Remove a value from the inner data structure. |
private java.lang.Object |
removeFromList(java.io.Serializable key,
java.lang.Object value) |
private java.lang.Object |
removeFromMap(java.io.Serializable key,
java.lang.String mapKey) |
void |
restoreState(FacesContext context,
java.lang.Object state)
One and only implementation of
restore state.
|
void |
restoreTransientState(FacesContext context,
java.lang.Object state)
Restore the "transient state" using the object passed as state. |
private java.lang.Object |
saveMap(FacesContext context,
java.util.Map<java.io.Serializable,java.lang.Object> map) |
java.lang.Object |
saveState(FacesContext context)
One and only implementation of
save-state - makes all other implementations
unnecessary.
|
java.lang.Object |
saveTransientState(FacesContext context)
Return the object containing related "transient states". |
void |
setTransient(boolean newTransientValue)
Denotes
whether or not the Object implementing this interface must or
must not participate in state saving or restoring.
|
private UIComponent component
private boolean isTransient
private java.util.Map<java.io.Serializable,java.lang.Object> deltaMap
private java.util.Map<java.io.Serializable,java.lang.Object> defaultMap
private java.util.Map<java.lang.Object,java.lang.Object> transientState
public ComponentStateHelper(UIComponent component)
public java.lang.Object put(java.io.Serializable key,
java.lang.Object value)
put in interface StateHelperkey - value - public java.lang.Object remove(java.io.Serializable key)
remove in interface StateHelperkey - public java.lang.Object put(java.io.Serializable key,
java.lang.String mapKey,
java.lang.Object value)
StateHelperStore the specified
mapKey/value in a Map that
is internal to the helper, and return the previously stored
value. The Map will then be associated with
key.
It's important to note for delta tracking that any
modifications to the internal Map be made through
this method or StateHelper.remove(java.io.Serializable,
Object).
put in interface StateHelperkey - the key of the map itselfmapKey - the key within the internal mapvalue - the value for the key in the internal mapStateHelper.put(java.io.Serializable, String, Object)public java.lang.Object get(java.io.Serializable key)
get in interface StateHelperkey - public java.lang.Object eval(java.io.Serializable key)
StateHelperAttempts to find a value associated with the specified key, using the value expression collection from the component if no such value is found.
eval in interface StateHelperkey - the name of the value in the internal map, or the name
of a value expression in the components value expression
collection.StateHelper.eval(java.io.Serializable)public java.lang.Object eval(java.io.Serializable key,
java.lang.Object defaultValue)
StateHelperPerforms the same logic as StateHelper.eval(java.io.Serializable) } but if no value is found, this
will return the specified defaultValue
eval in interface StateHelperkey - the key for which the value should be returned.defaultValue - the value to return if no value is found in
the call to eval().StateHelper.eval(java.io.Serializable, Object)public void add(java.io.Serializable key,
java.lang.Object value)
StateHelperStore the specified
value in a List that is internal to the
StateHelper.
It's important to note for delta
tracking that any modifications to the internal List
be made through this method or StateHelper.remove(java.io.Serializable, Object).
add in interface StateHelperkey - the key for which the value should be returned.value - the value to addStateHelper.add(java.io.Serializable, Object)public java.lang.Object remove(java.io.Serializable key,
java.lang.Object valueOrKey)
StateHelperRemove a value from the inner data
structure. Look in the inner data structure for the value at the
given key. If the value is a Map,
remove and return the value under the key given by the
valueOrKey argument. If the value is a
Collection, simply remove the value given by
the argument valueOrKey and return null.
remove in interface StateHelperkey - the key of in the inner data structure whose value is
a Collection or MapvalueOrKey - the value or key to be removed.StateHelper.remove(java.io.Serializable, Object)public java.lang.Object saveState(FacesContext context)
saveState in interface StateHoldercontext - public void restoreState(FacesContext context, java.lang.Object state)
restoreState in interface StateHoldercontext - FacesContextstate - the state to be restored.public boolean isTransient()
StateHolderIf true, the Object implementing this interface must not participate in state saving or restoring.
isTransient in interface StateHolderStateHolder.isTransient()public void setTransient(boolean newTransientValue)
StateHolderDenotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
setTransient in interface StateHoldernewTransientValue - boolean pass true if this
Object will not
participate in state saving or restoring, otherwise pass
false.StateHolder.setTransient(boolean)private java.lang.Object saveMap(FacesContext context, java.util.Map<java.io.Serializable,java.lang.Object> map)
private java.lang.Object removeFromList(java.io.Serializable key,
java.lang.Object value)
private java.lang.Object removeFromMap(java.io.Serializable key,
java.lang.String mapKey)
public java.lang.Object getTransient(java.lang.Object key)
TransientStateHelperReturn the value currently
associated with the specified key if any.
getTransient in interface TransientStateHelperkey - the key for which the value should be returned.public java.lang.Object getTransient(java.lang.Object key,
java.lang.Object defaultValue)
TransientStateHelperPerforms the same logic as TransientStateHelper.getTransient(java.lang.Object) } but if no value is found, this
will return the specified defaultValue
getTransient in interface TransientStateHelperkey - the key for which the value should be returned.defaultValue - the value to return if no value is found in
the call to get().public java.lang.Object putTransient(java.lang.Object key,
java.lang.Object value)
TransientStateHelperReturn the previously stored value and store the specified key/value pair. This is intended to store data that would otherwise reside in an instance variable on the component.
putTransient in interface TransientStateHelperkey - the key for the valuevalue - the valuepublic void restoreTransientState(FacesContext context, java.lang.Object state)
TransientStateHolderRestore the "transient state" using the object passed as state.
If the state
argument is null clear any previous transient
state if any and return.
restoreTransientState in interface TransientStateHolderstate - the object containing transient valuespublic java.lang.Object saveTransientState(FacesContext context)
TransientStateHolderReturn the object containing related "transient states". that could be used later to restore the "transient state".
saveTransientState in interface TransientStateHolder