Class MethodExpressionValueChangeListener
- All Implemented Interfaces:
StateHolder
,FacesListener
,ValueChangeListener
,EventListener
MethodExpressionValueChangeListener is a ValueChangeListener
that wraps
a MethodExpression
. When it receives a ValueChangeEvent
, it executes a method on an object identified
by the MethodExpression
.
-
Constructor Summary
ConstructorDescriptionMethodExpressionValueChangeListener
(MethodExpression methodExpressionOneArg) Construct aValueChangeListener
that contains aMethodExpression
.To accommodate method expression targets that take no arguments instead of taking aValueChangeEvent
argument, the implementation of this class must take the argumentmethodExpressionOneArg
, extract its expression string, and create anotherMethodExpression
whose expected param types match those of a zero argument method.MethodExpressionValueChangeListener
(MethodExpression methodExpressionOneArg, MethodExpression methodExpressionZeroArg) Construct aValueChangeListener
that contains aMethodExpression
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
If true, the Object implementing this interface must not participate in state saving or restoring.void
processValueChange
(ValueChangeEvent valueChangeEvent) Call through to theMethodExpression
passed in our constructor.void
restoreState
(FacesContext context, Object state) BothMethodExpression
instances described in the constructor must be restored.saveState
(FacesContext context) BothMethodExpression
instances described in the constructor must be saved.void
setTransient
(boolean newTransientValue) Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
-
Constructor Details
-
MethodExpressionValueChangeListener
public MethodExpressionValueChangeListener() -
MethodExpressionValueChangeListener
Construct a
ValueChangeListener
that contains aMethodExpression
.To accommodate method expression targets that take no arguments instead of taking aValueChangeEvent
argument, the implementation of this class must take the argumentmethodExpressionOneArg
, extract its expression string, and create anotherMethodExpression
whose expected param types match those of a zero argument method. The usage requirements for both of theseMethodExpression
instances are described inprocessValueChange(jakarta.faces.event.ValueChangeEvent)
.- Parameters:
methodExpressionOneArg
- aMethodExpression
that points to a method that returnsvoid
and takes a single argument of typeValueChangeEvent
.
-
MethodExpressionValueChangeListener
public MethodExpressionValueChangeListener(MethodExpression methodExpressionOneArg, MethodExpression methodExpressionZeroArg) Construct a
ValueChangeListener
that contains aMethodExpression
.- Parameters:
methodExpressionOneArg
- a method expression that takes one argumentmethodExpressionZeroArg
- a method expression that takes zero arguments
-
-
Method Details
-
processValueChange
Call through to the
MethodExpression
passed in our constructor. First, try to invoke theMethodExpression
passed to the constructor of this instance, passing the argumentValueChangeEvent
as the argument. If aMethodNotFoundException
is thrown, call to the zero argumentMethodExpression
derived from theMethodExpression
passed to the constructor of this instance. If that fails for any reason, throw anAbortProcessingException
, including the cause of the failure.- Specified by:
processValueChange
in interfaceValueChangeListener
- Parameters:
valueChangeEvent
- TheValueChangeEvent
that has occurred- Throws:
NullPointerException
- if the argument valueChangeEvent is null.AbortProcessingException
- Signal the Jakarta Server Faces implementation that no further processing on the current event should be performed
-
saveState
Both
MethodExpression
instances described in the constructor must be saved.- Specified by:
saveState
in interfaceStateHolder
- Parameters:
context
- the Faces context.- Returns:
- the saved state.
-
restoreState
Both
MethodExpression
instances described in the constructor must be restored.- Specified by:
restoreState
in interfaceStateHolder
- Parameters:
context
- the Faces context.state
- the state.
-
isTransient
public boolean isTransient()Description copied from interface:StateHolder
If true, the Object implementing this interface must not participate in state saving or restoring.
- Specified by:
isTransient
in interfaceStateHolder
- Returns:
true
if transient,false
otherwise.
-
setTransient
public void setTransient(boolean newTransientValue) Description copied from interface:StateHolder
Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
- Specified by:
setTransient
in interfaceStateHolder
- Parameters:
newTransientValue
- boolean passtrue
if this Object will not participate in state saving or restoring, otherwise passfalse
.
-