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 Summary
Fields 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.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 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.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
UICommandinstance with default property values.
-
-
Method Detail
-
getFamily
public 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 classUIComponent- Returns:
- the component family (not null).
-
isImmediate
public boolean isImmediate()
The immediate flag.
- Specified by:
isImmediatein interfaceActionSource- Returns:
trueif immediate,falseotherwise.
-
setImmediate
public void setImmediate(boolean immediate)
Description copied from interface:ActionSourceSet the "immediate execution" flag for this
UIComponent.- Specified by:
setImmediatein interfaceActionSource- Parameters:
immediate- The new immediate execution flag
-
getValue
public Object getValue()
Returns the
valueproperty 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
valueproperty of theUICommand. This is most often rendered as a label.- Parameters:
value- the new value
-
getActionExpression
public 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 interfaceActionSource2- Returns:
- the action expression.
-
setActionExpression
public 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 interfaceActionSource2- Parameters:
actionExpression- The new method expression
-
addActionListener
public 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 interfaceActionSource- Parameters:
listener- TheActionListenerto be added- Throws:
NullPointerException- iflistenerisnull
-
getActionListeners
public 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 interfaceActionSource- Returns:
- the action listeners, or a zero-length array.
-
removeActionListener
public 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 interfaceActionSource- Parameters:
listener- TheActionListenerto be removed- Throws:
NullPointerException- iflistenerisnull
-
broadcast
public 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 classUIComponentBase- Parameters:
event-FacesEventto 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 thisFacesEventis not supported by this componentNullPointerException- ifeventisnull
-
queueEvent
public void queueEvent(FacesEvent event)
Intercept
queueEventand take the following action. If the event is an, obtain theActionEventUIComponentinstance from the event. If the component is anobtain the value of its "immediate" property. If it is true, mark the phaseId for the event to beActionSourcePhaseId.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 classUIComponentBase- Parameters:
event-FacesEventto be queued
-
-