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 UIComponentthat 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: - ActionListeners, 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 rendererTypeproperty must be set to "jakarta.faces.Button". This value can be changed by calling thesetRendererType()method.
- 
- 
Field SummaryFields Modifier and Type Field Description static StringCOMPONENT_FAMILYThe standard component family for this component.static StringCOMPONENT_TYPEThe standard component type for this component.- 
Fields inherited from class jakarta.faces.component.UIComponentATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, FACETS_KEY, VIEW_LOCATION_KEY
 
- 
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddActionListener(ActionListener listener)Add a newActionListenerto the set of listeners interested in being notified whenActionEvents occur.voidbroadcast(FacesEvent event)In addition to to the defaultUIComponent.broadcast(jakarta.faces.event.FacesEvent)processing, pass theActionEventbeing broadcast to the method referenced byactionListener(if any), and to the defaultActionListenerregistered on theApplication.MethodExpressiongetActionExpression()Return theMethodExpressionpointing at the application action to be invoked, if thisUIComponentis activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediateproperty.ActionListener[]getActionListeners()Return the set of registeredActionListeners for thisActionSourceinstance.StringgetFamily()Return the identifier of the component family to which this component belongs.ObjectgetValue()Returns thevalueproperty of theUICommand.booleanisImmediate()The immediate flag.voidqueueEvent(FacesEvent event)InterceptqueueEventand take the following action.voidremoveActionListener(ActionListener listener)Remove an existingActionListener(if any) from the set of listeners interested in being notified whenActionEvents occur.voidsetActionExpression(MethodExpression actionExpression)Set theMethodExpressionpointing at the appication action to be invoked, if thisUIComponentis activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediateproperty.voidsetImmediate(boolean immediate)Set the "immediate execution" flag for thisUIComponent.voidsetValue(Object value)Sets thevalueproperty of theUICommand.- 
Methods inherited from class jakarta.faces.component.UIComponentBaseaddClientBehavior, 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.UIComponentencodeAll, 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_TYPEpublic static final String COMPONENT_TYPE The standard component type for this component. - See Also:
- Constant Field Values
 
 - 
COMPONENT_FAMILYpublic static final String COMPONENT_FAMILY The standard component family for this component. - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
UICommandpublic UICommand() Create a new UICommandinstance with default property values.
 
- 
 - 
Method Detail- 
getFamilypublic String getFamily() Description copied from class:UIComponentReturn the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the rendererTypeproperty, may be used to select the appropriateRendererfor this component instance. Note this method should NOT returnnull- Specified by:
- getFamilyin class- UIComponent
- Returns:
- the component family (not null).
 
 - 
isImmediatepublic boolean isImmediate() The immediate flag. - Specified by:
- isImmediatein interface- ActionSource
- Returns:
- trueif immediate,- falseotherwise.
 
 - 
setImmediatepublic void setImmediate(boolean immediate) Description copied from interface:ActionSourceSet the "immediate execution" flag for this UIComponent.- Specified by:
- setImmediatein interface- ActionSource
- Parameters:
- immediate- The new immediate execution flag
 
 - 
getValuepublic Object getValue() Returns the valueproperty of theUICommand. This is most often rendered as a label.- Returns:
- The object representing the value of this component.
 
 - 
setValuepublic void setValue(Object value) Sets the valueproperty of theUICommand. This is most often rendered as a label.- Parameters:
- value- the new value
 
 - 
getActionExpressionpublic MethodExpression getActionExpression() Description copied from interface:ActionSource2Return the MethodExpressionpointing at the application action to be invoked, if thisUIComponentis activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediateproperty.- Specified by:
- getActionExpressionin interface- ActionSource2
- Returns:
- the action expression.
 
 - 
setActionExpressionpublic void setActionExpression(MethodExpression actionExpression) Description copied from interface:ActionSource2Set the MethodExpressionpointing at the appication action to be invoked, if thisUIComponentis activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediateproperty.Any method referenced by such an expression must be public, with a return type of String, and accept no parameters.- Specified by:
- setActionExpressionin interface- ActionSource2
- Parameters:
- actionExpression- The new method expression
 
 - 
addActionListenerpublic void addActionListener(ActionListener listener) Description copied from interface:ActionSourceAdd a new ActionListenerto the set of listeners interested in being notified whenActionEvents occur.- Specified by:
- addActionListenerin interface- ActionSource
- Parameters:
- listener- The- ActionListenerto be added
- Throws:
- NullPointerException- if- listeneris- null
 
 - 
getActionListenerspublic ActionListener[] getActionListeners() Description copied from interface:ActionSourceReturn the set of registered ActionListeners for thisActionSourceinstance. If there are no registered listeners, a zero-length array is returned.- Specified by:
- getActionListenersin interface- ActionSource
- Returns:
- the action listeners, or a zero-length array.
 
 - 
removeActionListenerpublic void removeActionListener(ActionListener listener) Description copied from interface:ActionSourceRemove an existing ActionListener(if any) from the set of listeners interested in being notified whenActionEvents occur.- Specified by:
- removeActionListenerin interface- ActionSource
- Parameters:
- listener- The- ActionListenerto be removed
- Throws:
- NullPointerException- if- listeneris- null
 
 - 
broadcastpublic void broadcast(FacesEvent event) throws AbortProcessingException In addition to to the default UIComponent.broadcast(jakarta.faces.event.FacesEvent)processing, pass theActionEventbeing broadcast to the method referenced byactionListener(if any), and to the defaultActionListenerregistered on theApplication.- Overrides:
- broadcastin class- UIComponentBase
- Parameters:
- event-- FacesEventto be broadcast
- Throws:
- AbortProcessingException- Signal the Jakarta Faces implementation that no further processing on the current event should be performed
- IllegalArgumentException- if the implementation class of this- FacesEventis not supported by this component
- NullPointerException- if- eventis- null
 
 - 
queueEventpublic void queueEvent(FacesEvent event) Intercept queueEventand take the following action. If the event is anActionEventUIComponentinstance from the event. If the component is anActionSourcePhaseId.APPLY_REQUEST_VALUESotherwise, mark the phaseId to bePhaseId.INVOKE_APPLICATION. The event must be passed on tosuper.queueEvent()before returning from this method.- Overrides:
- queueEventin class- UIComponentBase
- Parameters:
- event-- FacesEventto be queued
 
 
- 
 
-