Class SimpleTransientStateHelper

java.lang.Object
org.apache.myfaces.core.api.shared.SimpleTransientStateHelper
All Implemented Interfaces:
TransientStateHelper, TransientStateHolder

public class SimpleTransientStateHelper extends Object implements TransientStateHelper
Lightweight 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 Details

    • SimpleTransientStateHelper

      public SimpleTransientStateHelper()
  • Method Details

    • getTransient

      public Object getTransient(Object key)
      Description copied from interface: TransientStateHelper

      Return the value currently associated with the specified key if any.

      Specified by:
      getTransient in interface TransientStateHelper
      Parameters:
      key - the key for which the value should be returned.
    • getTransient

      public Object getTransient(Object key, Object defaultValue)
      Scans directly so a stored null value is returned as-is, not conflated with "key absent" the way a v != null delegation would.
      Specified by:
      getTransient in interface TransientStateHelper
      Parameters:
      key - the key for which the value should be returned.
      defaultValue - the value to return if no value is found in the call to get().
    • putTransient

      public Object putTransient(Object key, Object value)
      Description copied from interface: TransientStateHelper

      Return 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:
      putTransient in interface TransientStateHelper
      Parameters:
      key - the key for the value
      value - the value
    • removeTransient

      public void removeTransient(Object key)
    • setOrRemoveTransient

      public void setOrRemoveTransient(Object key, Object value)
    • saveTransientState

      public Object saveTransientState(FacesContext context)
      Returns a compact snapshot of only the live key-value pairs. The snapshot is independent of the live array — a subsequent putTransient that grows _data will not affect it.
      Specified by:
      saveTransientState in interface TransientStateHolder
      Returns:
      object containing transient values
    • restoreTransientState

      public void restoreTransientState(FacesContext context, Object state)
      Description copied from interface: TransientStateHolder

      Restore the "transient state" using the object passed as state.

      If the state argument is null clear any previous transient state if any and return.

      Specified by:
      restoreTransientState in interface TransientStateHolder
      state - the object containing transient values
    • resetTransientState

      public void resetTransientState()