Class SimpleTransientStateHelper
- All Implemented Interfaces:
TransientStateHelper,TransientStateHolder
TransientStateHelper implementation for request-scoped
component state.
Uses a flat Object[] with a two-level key comparison: identity
(==) first for a fast path on enum-constant keys (e.g.
valid, localValueSet, submittedValue), then
equals() as a fallback for String or other keys that may be
re-instantiated after Java serialization/deserialization (a deserialized
String is a new heap object, not the interned literal).
Save and restore clone a compact array of only the live pairs, making
the round-trip O(n) with minimal allocation — critical for UIRepeat,
which saves and restores the transient state of every child component on
every row iteration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetTransient(Object key) Return the value currently associated with the specifiedkeyif any.getTransient(Object key, Object defaultValue) Scans directly so a storednullvalue is returned as-is, not conflated with "key absent" the way av != nulldelegation would.putTransient(Object key, Object value) Return the previously stored value and store the specified key/value pair.voidremoveTransient(Object key) voidvoidrestoreTransientState(FacesContext context, Object state) Restore the "transient state" using the object passed as state.saveTransientState(FacesContext context) Returns a compact snapshot of only the live key-value pairs.voidsetOrRemoveTransient(Object key, Object value)
-
Constructor Details
-
SimpleTransientStateHelper
public SimpleTransientStateHelper()
-
-
Method Details
-
getTransient
Description copied from interface:TransientStateHelperReturn the value currently associated with the specified
keyif any.- Specified by:
getTransientin interfaceTransientStateHelper- Parameters:
key- the key for which the value should be returned.
-
getTransient
Scans directly so a storednullvalue is returned as-is, not conflated with "key absent" the way av != nulldelegation would.- Specified by:
getTransientin interfaceTransientStateHelper- Parameters:
key- the key for which the value should be returned.defaultValue- the value to return if no value is found in the call toget().
-
putTransient
Description copied from interface: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.
- Specified by:
putTransientin interfaceTransientStateHelper- Parameters:
key- the key for the valuevalue- the value
-
removeTransient
-
setOrRemoveTransient
-
saveTransientState
Returns a compact snapshot of only the live key-value pairs. The snapshot is independent of the live array — a subsequentputTransientthat grows_datawill not affect it.- Specified by:
saveTransientStatein interfaceTransientStateHolder- Returns:
- object containing transient values
-
restoreTransientState
Description copied from interface:TransientStateHolderRestore the "transient state" using the object passed as state.
If the
stateargument isnullclear any previous transient state if any and return.- Specified by:
restoreTransientStatein interfaceTransientStateHolderstate- the object containing transient values
-
resetTransientState
public void resetTransientState()
-