Top Description Fields Constructors Methods
jakarta.faces.component

pack-priv Class ComponentStateHelper

extends Object
implements StateHelper, TransientStateHelper
Class Inheritance
All Implemented Interfaces
jakarta.faces.component.TransientStateHelper, jakarta.faces.component.TransientStateHolder, jakarta.faces.component.StateHelper, jakarta.faces.component.StateHolder
Annotations
@SuppressWarnings:unchecked
Static Imports
com.sun.faces.facelets.tag.faces.ComponentSupport.MARK_CREATED, .ComponentSupport.addToDescendantMarkIdCache, com.sun.faces.util.Util.coalesce, .Util.isEmpty, jakarta.faces.component.UIComponentBase.restoreAttachedState, .UIComponentBase.saveAttachedState

A base implementation for maps which implement the PartialStateHolder and TransientStateHolder interfaces. This can be used as a base-class for all state-holder implementations in components, converters and validators and other implementations of the StateHolder interface.

Field Summary

Modifier and TypeField and Description
private final UIComponent
private final Map<Serializable, Object>
private final Map<Serializable, Object>
private boolean
private Map<Object, Object>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(Serializable
the key for which the value should be returned.
key
,
Object
the value to add
value
)

Implements jakarta.faces.component.StateHelper.add.

Store the specified value in a List that is internal to the StateHelper.

public Object
eval(Serializable
the name of the value in the internal map, or the name of a value expression in the components value expression collection.
key
)

Implements jakarta.faces.component.StateHelper.eval.

Attempts to find a value associated with the specified key, using the value expression collection from the component if no such value is found.

public Object
eval(Serializable
the key for which the value should be returned.
key
,
Object
the value to return if no value is found in the call to eval().
defaultValue
)

Implements jakarta.faces.component.StateHelper.eval.

Performs the same logic as eval(java.io.Serializable) } but if no value is found, this will return the specified defaultValue

public Object
eval(Serializable
the key for which the value should be returned.
key
,
Supplier<Object>
the supplier used to evaluate the default value if no value is found in the call to eval().
defaultValueSupplier
)

Implements jakarta.faces.component.StateHelper.eval.

Performs the same logic as eval(java.io.Serializable) } but if no value is found, this will return the return-value of the defaultValueSupplier

public Object
get(Serializable key)

Implements jakarta.faces.component.StateHelper.get.

Get the object from the main-map.

public Object
getTransient(Object
the key for which the value should be returned.
key
)

Implements jakarta.faces.component.TransientStateHelper.getTransient.

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

public Object
getTransient(Object
the key for which the value should be returned.
key
,
Object
the value to return if no value is found in the call to get().
defaultValue
)

Implements jakarta.faces.component.TransientStateHelper.getTransient.

Performs the same logic as getTransient } but if no value is found, this will return the specified defaultValue

private void
private void
private void
public boolean
isTransient()

Implements jakarta.faces.component.StateHolder.isTransient.

If true, the Object implementing this interface must not participate in state saving or restoring.

public Object

Returns:

the original value in the delta-map, if not present, the old value in the main map
put
(Serializable key, Object value)

Implements jakarta.faces.component.StateHelper.put.

Put the object in the main-map and/or the delta-map, if necessary.

public Object
put(Serializable
the key of the map itself
key
,
String
the key within the internal map
mapKey
,
Object
the value for the key in the internal map
value
)

Implements jakarta.faces.component.StateHelper.put.

Store the specified mapKey/value in a Map that is internal to the helper, and return the previously stored value.

public Object
putTransient(Object
the key for the value
key
,
Object
the value
value
)

Implements jakarta.faces.component.TransientStateHelper.putTransient.

Return the previously stored value and store the specified key/value pair.

public Object

Returns:

the removed object in the delta-map. if not present, the removed object from the main map
remove
(Serializable key)

Implements jakarta.faces.component.StateHelper.remove.

We need to remove from both maps, if we do remove an existing key.

public Object
remove(Serializable
the key of in the inner data structure whose value is a Collection or Map
key
,
Object
the value or key to be removed.
valueOrKey
)

Implements jakarta.faces.component.StateHelper.remove.

Remove a value from the inner data structure.

private Object
private Object
public void
restoreState(FacesContext
FacesContext
context
,
Object
the state to be restored.
state
)

Implements jakarta.faces.component.StateHolder.restoreState.

One and only implementation of restore state.

public void
restoreTransientState(FacesContext
the Faces context
context
,
Object
the object containing transient values
state
)

Implements jakarta.faces.component.TransientStateHolder.restoreTransientState.

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

private Object
public Object

Returns:

the saved state
saveState
(FacesContext context)

Implements jakarta.faces.component.StateHolder.saveState.

One and only implementation of save-state - makes all other implementations unnecessary.

public Object
saveTransientState(FacesContext
the Faces context.
context
)

Implements jakarta.faces.component.TransientStateHolder.saveTransientState.

Return the object containing related "transient states".

public void
setTransient(boolean
boolean pass true if this Object will not participate in state saving or restoring, otherwise pass false.
newTransientValue
)

Implements jakarta.faces.component.StateHolder.setTransient.

Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

componentback to summary
private final UIComponent component
defaultMapback to summary
private final Map<Serializable, Object> defaultMap
deltaMapback to summary
private final Map<Serializable, Object> deltaMap
isTransientback to summary
private boolean isTransient
transientStateback to summary
private Map<Object, Object> transientState

Constructor Detail

ComponentStateHelperback to summary
public ComponentStateHelper(UIComponent component)

Method Detail

addback to summary
public void add(Serializable key, Object value)

Implements jakarta.faces.component.StateHelper.add.

Doc from jakarta.faces.component.StateHelper.add.

Store 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).

Parameters
key:Serializable

the key for which the value should be returned.

value:Object

the value to add

Annotations
@Override
See Also
StateHelper#add(java.io.Serializable, Object)
evalback to summary
public Object eval(Serializable key)

Implements jakarta.faces.component.StateHelper.eval.

Doc from jakarta.faces.component.StateHelper.eval.

Attempts to find a value associated with the specified key, using the value expression collection from the component if no such value is found.

Parameters
key:Serializable

the name of the value in the internal map, or the name of a value expression in the components value expression collection.

Returns:Object

the evaluated value.

Annotations
@Override
See Also
StateHelper#eval(java.io.Serializable)
evalback to summary
public Object eval(Serializable key, Object defaultValue)

Implements jakarta.faces.component.StateHelper.eval.

Doc from jakarta.faces.component.StateHelper.eval.

Performs the same logic as eval(java.io.Serializable) } but if no value is found, this will return the specified defaultValue

Parameters
key:Serializable

the key for which the value should be returned.

defaultValue:Object

the value to return if no value is found in the call to eval().

Returns:Object

the evaluated value.

Annotations
@Override
See Also
StateHelper#eval(java.io.Serializable, Object)
evalback to summary
public Object eval(Serializable key, Supplier<Object> defaultValueSupplier)

Implements jakarta.faces.component.StateHelper.eval.

Doc from jakarta.faces.component.StateHelper.eval.

Performs the same logic as eval(java.io.Serializable) } but if no value is found, this will return the return-value of the defaultValueSupplier

Parameters
key:Serializable

the key for which the value should be returned.

defaultValueSupplier:Supplier<Object>

the supplier used to evaluate the default value if no value is found in the call to eval().

Returns:Object

the evaluated value.

Annotations
@Override
See Also
StateHelper#eval(java.io.Serializable, Supplier)
getback to summary
public Object get(Serializable key)

Implements jakarta.faces.component.StateHelper.get.

Get the object from the main-map. As everything is written through from the delta-map to the main-map, this should be enough.

Returns:Object

Doc from jakarta.faces.component.StateHelper.get.

the value.

Annotations
@Override
getTransientback to summary
public Object getTransient(Object key)

Implements jakarta.faces.component.TransientStateHelper.getTransient.

Doc from jakarta.faces.component.TransientStateHelper.getTransient.

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

Parameters
key:Object

the key for which the value should be returned.

Returns:Object

the stored value.

Annotations
@Override
getTransientback to summary
public Object getTransient(Object key, Object defaultValue)

Implements jakarta.faces.component.TransientStateHelper.getTransient.

Doc from jakarta.faces.component.TransientStateHelper.getTransient.

Performs the same logic as getTransient } but if no value is found, this will return the specified defaultValue

Parameters
key:Object

the key for which the value should be returned.

defaultValue:Object

the value to return if no value is found in the call to get().

Returns:Object

the stored value.

Annotations
@Override
handleAttributeback to summary
private void handleAttribute(String name, Object value)
initListback to summary
private void initList(Serializable key)
initMapback to summary
private void initMap(Serializable key)
isTransientback to summary
public boolean isTransient()

Implements jakarta.faces.component.StateHolder.isTransient.

Doc from jakarta.faces.component.StateHolder.isTransient.

If true, the Object implementing this interface must not participate in state saving or restoring.

Returns:boolean

true if transient, false otherwise.

Annotations
@Override
See Also
jakarta.faces.component.StateHolder#isTransient()
putback to summary
public Object put(Serializable key, Object value)

Implements jakarta.faces.component.StateHelper.put.

Put the object in the main-map and/or the delta-map, if necessary.

Returns:Object

the original value in the delta-map, if not present, the old value in the main map

Annotations
@Override
putback to summary
public Object put(Serializable key, String mapKey, Object value)

Implements jakarta.faces.component.StateHelper.put.

Doc from jakarta.faces.component.StateHelper.put.

Store 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).

Parameters
key:Serializable

the key of the map itself

mapKey:String

the key within the internal map

value:Object

the value for the key in the internal map

Returns:Object

the value.

Annotations
@Override
See Also
StateHelper#put(java.io.Serializable, String, Object)
putTransientback to summary
public Object putTransient(Object key, Object value)

Implements jakarta.faces.component.TransientStateHelper.putTransient.

Doc from jakarta.faces.component.TransientStateHelper.putTransient.

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.

Parameters
key:Object

the key for the value

value:Object

the value

Returns:Object

the previously stored value

Annotations
@Override
removeback to summary
public Object remove(Serializable key)

Implements jakarta.faces.component.StateHelper.remove.

We need to remove from both maps, if we do remove an existing key.

Returns:Object

the removed object in the delta-map. if not present, the removed object from the main map

Annotations
@Override
removeback to summary
public Object remove(Serializable key, Object valueOrKey)

Implements jakarta.faces.component.StateHelper.remove.

Doc from jakarta.faces.component.StateHelper.remove.

Remove 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.

Parameters
key:Serializable

the key of in the inner data structure whose value is a Collection or Map

valueOrKey:Object

the value or key to be removed.

Returns:Object

the removed value.

Annotations
@Override
See Also
StateHelper#remove(java.io.Serializable, Object)
removeFromListback to summary
private Object removeFromList(Serializable key, Object value)
removeFromMapback to summary
private Object removeFromMap(Serializable key, String mapKey)
restoreStateback to summary
public void restoreState(FacesContext context, Object state)

Implements jakarta.faces.component.StateHolder.restoreState.

One and only implementation of restore state. Makes all other implementations unnecessary.

Parameters
context:FacesContext

FacesContext

state:Object

the state to be restored.

Annotations
@Override
restoreTransientStateback to summary
public void restoreTransientState(FacesContext context, Object state)

Implements jakarta.faces.component.TransientStateHolder.restoreTransientState.

Doc from jakarta.faces.component.TransientStateHolder.restoreTransientState.

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.

Parameters
context:FacesContext

the Faces context

state:Object

the object containing transient values

Annotations
@Override
saveMapback to summary
private Object saveMap(FacesContext context, Map<Serializable, Object> map)
saveStateback to summary
public Object saveState(FacesContext context)

Implements jakarta.faces.component.StateHolder.saveState.

One and only implementation of save-state - makes all other implementations unnecessary.

Returns:Object

the saved state

Annotations
@Override
saveTransientStateback to summary
public Object saveTransientState(FacesContext context)

Implements jakarta.faces.component.TransientStateHolder.saveTransientState.

Doc from jakarta.faces.component.TransientStateHolder.saveTransientState.

Return the object containing related "transient states". that could be used later to restore the "transient state".

Parameters
context:FacesContext

the Faces context.

Returns:Object

object containing transient values

Annotations
@Override
setTransientback to summary
public void setTransient(boolean newTransientValue)

Implements jakarta.faces.component.StateHolder.setTransient.

Doc from jakarta.faces.component.StateHolder.setTransient.

Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.

Parameters
newTransientValue:boolean

boolean pass true if this Object will not participate in state saving or restoring, otherwise pass false.

Annotations
@Override
See Also
StateHolder#setTransient(boolean)