Class MethodExpressionValueChangeListener
- java.lang.Object
-
- jakarta.faces.event.MethodExpressionValueChangeListener
-
- All Implemented Interfaces:
StateHolder,FacesListener,ValueChangeListener,EventListener
public class MethodExpressionValueChangeListener extends Object implements ValueChangeListener, StateHolder
MethodExpressionValueChangeListener is a
ValueChangeListenerthat wraps aMethodExpression. When it receives aValueChangeEvent, it executes a method on an object identified by theMethodExpression.
-
-
Constructor Summary
Constructors Constructor Description MethodExpressionValueChangeListener()MethodExpressionValueChangeListener(MethodExpression methodExpressionOneArg)Construct aValueChangeListenerthat contains aMethodExpression.To accommodate method expression targets that take no arguments instead of taking aValueChangeEventargument, the implementation of this class must take the argumentmethodExpressionOneArg, extract its expression string, and create anotherMethodExpressionwhose expected param types match those of a zero argument method.MethodExpressionValueChangeListener(MethodExpression methodExpressionOneArg, MethodExpression methodExpressionZeroArg)Construct aValueChangeListenerthat contains aMethodExpression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisTransient()If true, the Object implementing this interface must not participate in state saving or restoring.voidprocessValueChange(ValueChangeEvent valueChangeEvent)Call through to theMethodExpressionpassed in our constructor.voidrestoreState(FacesContext context, Object state)BothMethodExpressioninstances described in the constructor must be restored.ObjectsaveState(FacesContext context)BothMethodExpressioninstances described in the constructor must be saved.voidsetTransient(boolean newTransientValue)Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
-
-
-
Constructor Detail
-
MethodExpressionValueChangeListener
public MethodExpressionValueChangeListener()
-
MethodExpressionValueChangeListener
public MethodExpressionValueChangeListener(MethodExpression methodExpressionOneArg)
Construct a
ValueChangeListenerthat contains aMethodExpression.To accommodate method expression targets that take no arguments instead of taking aValueChangeEventargument, the implementation of this class must take the argumentmethodExpressionOneArg, extract its expression string, and create anotherMethodExpressionwhose expected param types match those of a zero argument method. The usage requirements for both of theseMethodExpressioninstances are described inprocessValueChange(jakarta.faces.event.ValueChangeEvent).- Parameters:
methodExpressionOneArg- aMethodExpressionthat points to a method that returnsvoidand takes a single argument of typeValueChangeEvent.
-
MethodExpressionValueChangeListener
public MethodExpressionValueChangeListener(MethodExpression methodExpressionOneArg, MethodExpression methodExpressionZeroArg)
Construct a
ValueChangeListenerthat contains aMethodExpression.- Parameters:
methodExpressionOneArg- a method expression that takes one argumentmethodExpressionZeroArg- a method expression that takes zero arguments
-
-
Method Detail
-
processValueChange
public void processValueChange(ValueChangeEvent valueChangeEvent) throws AbortProcessingException
Call through to the
MethodExpressionpassed in our constructor. First, try to invoke theMethodExpressionpassed to the constructor of this instance, passing the argumentValueChangeEventas the argument. If aMethodNotFoundExceptionis thrown, call to the zero argumentMethodExpressionderived from theMethodExpressionpassed to the constructor of this instance. If that fails for any reason, throw anAbortProcessingException, including the cause of the failure.- Specified by:
processValueChangein interfaceValueChangeListener- Parameters:
valueChangeEvent- TheValueChangeEventthat has occurred- Throws:
NullPointerException- if the argument valueChangeEvent is null.AbortProcessingException- Signal the Jakarta Faces implementation that no further processing on the current event should be performed
-
saveState
public Object saveState(FacesContext context)
Both
MethodExpressioninstances described in the constructor must be saved.- Specified by:
saveStatein interfaceStateHolder- Parameters:
context- the Faces context.- Returns:
- the saved state.
-
restoreState
public void restoreState(FacesContext context, Object state)
Both
MethodExpressioninstances described in the constructor must be restored.- Specified by:
restoreStatein interfaceStateHolder- Parameters:
context- the Faces context.state- the state.
-
isTransient
public boolean isTransient()
Description copied from interface:StateHolderIf true, the Object implementing this interface must not participate in state saving or restoring.
- Specified by:
isTransientin interfaceStateHolder- Returns:
trueif transient,falseotherwise.
-
setTransient
public void setTransient(boolean newTransientValue)
Description copied from interface:StateHolderDenotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
- Specified by:
setTransientin interfaceStateHolder- Parameters:
newTransientValue- boolean passtrueif this Object will not participate in state saving or restoring, otherwise passfalse.
-
-