public class UICommand extends UIComponentBase implements ActionSource2
UICommand is a UIComponent
that represents a user interface component which, when activated
by the user, triggers an application specific "command" or "action". Such a component is typically rendered as a push
button, a menu item, or a hyperlink.
When the decode()
method of this UICommand
, or its corresponding Renderer
, detects that
this control has been activated, it will queue an ActionEvent
. Later on, the broadcast()
method
will ensure that this event is broadcast to all interested listeners.
Listeners will be invoked in the following order:
ActionListener
s, in the order in which they were registered.
MethodExpression
(which will cover the "actionListener" that was set as a
MethodBinding
).
ActionListener
, retrieved from the Application
- and therefore, any attached "action"
MethodExpression
.
By default, the rendererType
property must be set to "jakarta.faces.Button
". This value can
be changed by calling the setRendererType()
method.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMPONENT_FAMILY
The standard component family for this component.
|
static java.lang.String |
COMPONENT_TYPE
The standard component type for this component.
|
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, FACETS_KEY, VIEW_LOCATION_KEY
Constructor and Description |
---|
UICommand()
Create a new
UICommand instance with default property values. |
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener listener)
Add a new
ActionListener to the set of listeners interested in being notified when ActionEvent s
occur. |
void |
broadcast(FacesEvent event)
In addition to to the default
UIComponent.broadcast(jakarta.faces.event.FacesEvent) processing, pass the ActionEvent being broadcast
to the method referenced by actionListener (if any), and to the default ActionListener
registered on the Application . |
MethodExpression |
getActionExpression()
Return the
MethodExpression pointing at the application action to be invoked, if this UIComponent is
activated by the user, during the Apply Request Values or Invoke Application phase of the request
processing lifecycle, depending on the value of the immediate property. |
ActionListener[] |
getActionListeners()
Return the set of registered
ActionListener s for this ActionSource instance. |
java.lang.String |
getFamily()
Return the identifier of the component family to which this component belongs. |
java.lang.Object |
getValue()
Returns the
value property of the UICommand . |
boolean |
isImmediate()
The immediate flag.
|
void |
queueEvent(FacesEvent event)
Intercept
queueEvent and take the following action. |
void |
removeActionListener(ActionListener listener)
Remove an existing
ActionListener (if any) from the set of listeners interested in being notified when
ActionEvent s occur. |
void |
setActionExpression(MethodExpression actionExpression)
Set the
MethodExpression pointing at the appication action to be invoked, if this UIComponent is
activated by the user, during the Apply Request Values or Invoke Application phase of the request
processing lifecycle, depending on the value of the immediate property. |
void |
setImmediate(boolean immediate)
Set the "immediate execution" flag for this
UIComponent . |
void |
setValue(java.lang.Object value)
Sets the
value property of the UICommand . |
addClientBehavior, addFacesListener, clearInitialState, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, subscribeToEvent, unsubscribeFromEvent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
public static final java.lang.String COMPONENT_TYPE
The standard component type for this component.
public static final java.lang.String COMPONENT_FAMILY
The standard component family for this component.
public UICommand()
Create a new UICommand
instance with default property values.
public java.lang.String getFamily()
UIComponent
Return the identifier of the component family to which this component belongs. This identifier, in conjunction with
the value of the rendererType
property, may be used to select the appropriate Renderer
for this
component instance. Note this method should NOT return null
getFamily
in class UIComponent
public boolean isImmediate()
The immediate flag.
isImmediate
in interface ActionSource
true
if immediate, false
otherwise.public void setImmediate(boolean immediate)
ActionSource
Set the "immediate execution" flag for this UIComponent
.
setImmediate
in interface ActionSource
immediate
- The new immediate execution flagpublic java.lang.Object getValue()
Returns the value
property of the UICommand
. This is most often rendered as a label.
public void setValue(java.lang.Object value)
Sets the value
property of the UICommand
. This is most often rendered as a label.
value
- the new valuepublic MethodExpression getActionExpression()
ActionSource2
Return the MethodExpression
pointing at the application action to be invoked, if this UIComponent
is
activated by the user, during the Apply Request Values or Invoke Application phase of the request
processing lifecycle, depending on the value of the immediate
property.
getActionExpression
in interface ActionSource2
public void setActionExpression(MethodExpression actionExpression)
ActionSource2
Set the MethodExpression
pointing at the appication action to be invoked, if this UIComponent
is
activated by the user, during the Apply Request Values or Invoke Application phase of the request
processing lifecycle, depending on the value of the immediate
property.
Any method referenced by such an expression must be public, with a return type of String
, and accept no
parameters.
setActionExpression
in interface ActionSource2
actionExpression
- The new method expressionpublic void addActionListener(ActionListener listener)
ActionSource
Add a new ActionListener
to the set of listeners interested in being notified when ActionEvent
s
occur.
addActionListener
in interface ActionSource
listener
- The ActionListener
to be addedjava.lang.NullPointerException
- if listener
is null
public ActionListener[] getActionListeners()
ActionSource
Return the set of registered ActionListener
s for this ActionSource
instance. If there are no
registered listeners, a zero-length array is returned.
getActionListeners
in interface ActionSource
public void removeActionListener(ActionListener listener)
ActionSource
Remove an existing ActionListener
(if any) from the set of listeners interested in being notified when
ActionEvent
s occur.
removeActionListener
in interface ActionSource
listener
- The ActionListener
to be removedjava.lang.NullPointerException
- if listener
is null
public void broadcast(FacesEvent event) throws AbortProcessingException
In addition to to the default UIComponent.broadcast(jakarta.faces.event.FacesEvent)
processing, pass the ActionEvent
being broadcast
to the method referenced by actionListener
(if any), and to the default ActionListener
registered on the Application
.
broadcast
in class UIComponentBase
event
- FacesEvent
to be broadcastAbortProcessingException
- Signal the Jakarta Faces implementation that no further processing on the
current event should be performedjava.lang.IllegalArgumentException
- if the implementation class of this FacesEvent
is not supported by this
componentjava.lang.NullPointerException
- if event
is null
public void queueEvent(FacesEvent event)
Intercept queueEvent
and take the following action. If the event is an
,
obtain the ActionEvent
UIComponent
instance from the event. If the component is an
obtain the value of its "immediate" property. If it is true, mark the phaseId for the event to be
ActionSource
PhaseId.APPLY_REQUEST_VALUES
otherwise, mark the phaseId to be PhaseId.INVOKE_APPLICATION
.
The event must be passed on to super.queueEvent()
before returning from this method.
queueEvent
in class UIComponentBase
event
- FacesEvent
to be queued