Top Description Methods
jakarta.faces.component

public Interface StateHelper

extends StateHolder
Known Direct Implementers
jakarta.faces.component.ComponentStateHelper
Imports
java.io.Serializable, java.util.function.Supplier

Define a Map-like contract that makes it easier for components to implement PartialStateHolder. Each UIComponent in the view will return an implementation of this interface from its UIComponent#getStateHelper method.

Since
2.0

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
)

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

public Object

Returns:

the evaluated value.
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
)

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

Returns:

the evaluated value.
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
)

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

public Object

Returns:

the evaluated value.
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
)

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

Returns:

the value.
get
(Serializable
the key for which the value should be returned.
key
)

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

public Object

Returns:

the previously stored value
put
(Serializable
the key for the value
key
,
Object
the value
value
)

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

public Object

Returns:

the value.
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
)

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

public Object

Returns:

the removed value.
remove
(Serializable
the key to remove
key
)

Remove the key/value pair from the helper, returning the value previously stored under this key.

public Object

Returns:

the removed value.
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
)

Remove a value from the inner data structure.

Inherited from jakarta.faces.component.StateHolder:
isTransientrestoreStatesaveStatesetTransient

Method Detail

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

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

Since
2.0
evalback to summary
public Object eval(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.

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.

Since
2.0
evalback to summary
public Object eval(Serializable key, Object defaultValue)

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.

Since
2.0
evalback to summary
public Object eval(Serializable key, Supplier<Object> defaultValueSupplier)

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.

Since
4.0
getback to summary
public Object get(Serializable key)

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

Parameters
key:Serializable

the key for which the value should be returned.

Returns:Object

the value.

Since
2.0
putback to summary
public Object put(Serializable key, Object value)

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:Serializable

the key for the value

value:Object

the value

Returns:Object

the previously stored value

Since
2.0
putback to summary
public Object put(Serializable key, String mapKey, Object value)

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.

Since
2.0
removeback to summary
public Object remove(Serializable key)

Remove the key/value pair from the helper, returning the value previously stored under this key.

Parameters
key:Serializable

the key to remove

Returns:Object

the removed value.

Since
2.0
removeback to summary
public Object remove(Serializable key, Object valueOrKey)

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.