Class UICommand
- java.lang.Object
-
- jakarta.faces.component.UIComponent
-
- jakarta.faces.component.UIComponentBase
-
- jakarta.faces.component.UICommand
-
- All Implemented Interfaces:
ActionSource
,ActionSource2
,PartialStateHolder
,StateHolder
,TransientStateHolder
,ComponentSystemEventListener
,FacesListener
,SystemEventListenerHolder
,EventListener
- Direct Known Subclasses:
HtmlCommandButton
,HtmlCommandLink
,HtmlCommandScript
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 thisUICommand
, or its correspondingRenderer
, detects that this control has been activated, it will queue anActionEvent
. Later on, thebroadcast()
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.- The "actionListener"
MethodExpression
(which will cover the "actionListener" that was set as aMethodBinding
). - The default
ActionListener
, retrieved from theApplication
- 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 thesetRendererType()
method.
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPONENT_FAMILY
The standard component family for this component.static String
COMPONENT_TYPE
The standard component type for this component.-
Fields inherited from class jakarta.faces.component.UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, FACETS_KEY, VIEW_LOCATION_KEY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActionListener(ActionListener listener)
Add a newActionListener
to the set of listeners interested in being notified whenActionEvent
s occur.void
broadcast(FacesEvent event)
In addition to to the defaultUIComponent.broadcast(jakarta.faces.event.FacesEvent)
processing, pass theActionEvent
being broadcast to the method referenced byactionListener
(if any), and to the defaultActionListener
registered on theApplication
.MethodExpression
getActionExpression()
Return theMethodExpression
pointing at the application action to be invoked, if thisUIComponent
is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediate
property.ActionListener[]
getActionListeners()
Return the set of registeredActionListener
s for thisActionSource
instance.String
getFamily()
Return the identifier of the component family to which this component belongs.Object
getValue()
Returns thevalue
property of theUICommand
.boolean
isImmediate()
The immediate flag.void
queueEvent(FacesEvent event)
InterceptqueueEvent
and take the following action.void
removeActionListener(ActionListener listener)
Remove an existingActionListener
(if any) from the set of listeners interested in being notified whenActionEvent
s occur.void
setActionExpression(MethodExpression actionExpression)
Set theMethodExpression
pointing at the appication action to be invoked, if thisUIComponent
is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediate
property.void
setImmediate(boolean immediate)
Set the "immediate execution" flag for thisUIComponent
.void
setValue(Object value)
Sets thevalue
property of theUICommand
.-
Methods inherited from class jakarta.faces.component.UIComponentBase
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
-
Methods inherited from class jakarta.faces.component.UIComponent
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
-
-
-
-
Field Detail
-
COMPONENT_TYPE
public static final String COMPONENT_TYPE
The standard component type for this component.
- See Also:
- Constant Field Values
-
COMPONENT_FAMILY
public static final String COMPONENT_FAMILY
The standard component family for this component.
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UICommand
public UICommand()
Create a new
UICommand
instance with default property values.
-
-
Method Detail
-
getFamily
public String getFamily()
Description copied from class: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 appropriateRenderer
for this component instance. Note this method should NOT returnnull
- Specified by:
getFamily
in classUIComponent
- Returns:
- the component family (not null).
-
isImmediate
public boolean isImmediate()
The immediate flag.
- Specified by:
isImmediate
in interfaceActionSource
- Returns:
true
if immediate,false
otherwise.
-
setImmediate
public void setImmediate(boolean immediate)
Description copied from interface:ActionSource
Set the "immediate execution" flag for this
UIComponent
.- Specified by:
setImmediate
in interfaceActionSource
- Parameters:
immediate
- The new immediate execution flag
-
getValue
public Object getValue()
Returns the
value
property of theUICommand
. This is most often rendered as a label.- Returns:
- The object representing the value of this component.
-
setValue
public void setValue(Object value)
Sets the
value
property of theUICommand
. This is most often rendered as a label.- Parameters:
value
- the new value
-
getActionExpression
public MethodExpression getActionExpression()
Description copied from interface:ActionSource2
Return the
MethodExpression
pointing at the application action to be invoked, if thisUIComponent
is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediate
property.- Specified by:
getActionExpression
in interfaceActionSource2
- Returns:
- the action expression.
-
setActionExpression
public void setActionExpression(MethodExpression actionExpression)
Description copied from interface:ActionSource2
Set the
MethodExpression
pointing at the appication action to be invoked, if thisUIComponent
is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediate
property.Any method referenced by such an expression must be public, with a return type of
String
, and accept no parameters.- Specified by:
setActionExpression
in interfaceActionSource2
- Parameters:
actionExpression
- The new method expression
-
addActionListener
public void addActionListener(ActionListener listener)
Description copied from interface:ActionSource
Add a new
ActionListener
to the set of listeners interested in being notified whenActionEvent
s occur.- Specified by:
addActionListener
in interfaceActionSource
- Parameters:
listener
- TheActionListener
to be added- Throws:
NullPointerException
- iflistener
isnull
-
getActionListeners
public ActionListener[] getActionListeners()
Description copied from interface:ActionSource
Return the set of registered
ActionListener
s for thisActionSource
instance. If there are no registered listeners, a zero-length array is returned.- Specified by:
getActionListeners
in interfaceActionSource
- Returns:
- the action listeners, or a zero-length array.
-
removeActionListener
public void removeActionListener(ActionListener listener)
Description copied from interface:ActionSource
Remove an existing
ActionListener
(if any) from the set of listeners interested in being notified whenActionEvent
s occur.- Specified by:
removeActionListener
in interfaceActionSource
- Parameters:
listener
- TheActionListener
to be removed- Throws:
NullPointerException
- iflistener
isnull
-
broadcast
public void broadcast(FacesEvent event) throws AbortProcessingException
In addition to to the default
UIComponent.broadcast(jakarta.faces.event.FacesEvent)
processing, pass theActionEvent
being broadcast to the method referenced byactionListener
(if any), and to the defaultActionListener
registered on theApplication
.- Overrides:
broadcast
in classUIComponentBase
- Parameters:
event
-FacesEvent
to be broadcast- Throws:
AbortProcessingException
- Signal the Jakarta Faces implementation that no further processing on the current event should be performedIllegalArgumentException
- if the implementation class of thisFacesEvent
is not supported by this componentNullPointerException
- ifevent
isnull
-
queueEvent
public void queueEvent(FacesEvent event)
Intercept
queueEvent
and take the following action. If the event is an
, obtain theActionEvent
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 beActionSource
PhaseId.APPLY_REQUEST_VALUES
otherwise, mark the phaseId to bePhaseId.INVOKE_APPLICATION
. The event must be passed on tosuper.queueEvent()
before returning from this method.- Overrides:
queueEvent
in classUIComponentBase
- Parameters:
event
-FacesEvent
to be queued
-
-