javax.faces.component
Class UICommand

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UICommand
All Implemented Interfaces:
ActionSource, ActionSource2, StateHolder
Direct Known Subclasses:
HtmlCommandButton, HtmlCommandLink

public class UICommand
extends UIComponentBase
implements ActionSource2

Events:

Type Phases Description
javax.faces.event.ActionEvent Invoke
Application
Apply
Request
Values
Event delivered when the "action" of the component has been invoked; for example, by clicking on a button. The action may result in page navigation.


Field Summary
static java.lang.String COMPONENT_FAMILY
           
static java.lang.String COMPONENT_TYPE
           
 
Fields inherited from class javax.faces.component.UIComponent
bindings
 
Constructor Summary
UICommand()
          Construct an instance of the UICommand.
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds a action listener.
 void broadcast(FacesEvent event)
          Invoke any listeners attached to this object which are listening for an event whose type matches the specified event's runtime type.
 MethodBinding getAction()
          Deprecated. Use getActionExpression() instead.
 javax.el.MethodExpression getActionExpression()
          Gets Specifies the action to take when this command is invoked.
 MethodBinding getActionListener()
          Deprecated.  
 ActionListener[] getActionListeners()
          Returns an array of attached action listeners.
 java.lang.String getFamily()
           
 java.lang.Object getValue()
          Gets The initial value of this component.
 boolean isImmediate()
          Gets A boolean value that identifies the phase during which action events should fire.
 void queueEvent(FacesEvent event)
           
 void removeActionListener(ActionListener listener)
          Removes a action listener.
 void restoreState(FacesContext facesContext, java.lang.Object state)
          Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into the provided state object.
 java.lang.Object saveState(FacesContext facesContext)
          Invoked after the render phase has completed, this method returns an object which can be passed to the restoreState of some other instance of UIComponentBase to reset that object's state to the same values as this object currently has.
 void setAction(MethodBinding action)
          Deprecated. Use setActionExpression instead.
 void setActionExpression(javax.el.MethodExpression actionExpression)
          Sets Specifies the action to take when this command is invoked.
 void setActionListener(MethodBinding actionListener)
          Deprecated.  
 void setImmediate(boolean immediate)
          Sets A boolean value that identifies the phase during which action events should fire.
 void setValue(java.lang.Object value)
          Sets The initial value of this component.
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId, getValueExpression, setValueExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_FAMILY

public static final java.lang.String COMPONENT_FAMILY
See Also:
Constant Field Values

COMPONENT_TYPE

public static final java.lang.String COMPONENT_TYPE
See Also:
Constant Field Values
Constructor Detail

UICommand

public UICommand()
Construct an instance of the UICommand.

Method Detail

setAction

public void setAction(MethodBinding action)
Deprecated. Use setActionExpression instead.

Specified by:
setAction in interface ActionSource

getAction

public MethodBinding getAction()
Deprecated. Use getActionExpression() instead.

Specified by:
getAction in interface ActionSource

broadcast

public void broadcast(FacesEvent event)
               throws AbortProcessingException
Description copied from class: UIComponentBase
Invoke any listeners attached to this object which are listening for an event whose type matches the specified event's runtime type.

This method does not propagate the event up to parent components, ie listeners attached to parent components don't automatically get called.

If any of the listeners throws AbortProcessingException then that exception will prevent any further listener callbacks from occurring, and the exception propagates out of this method without alteration.

ActionEvent events are typically queued by the renderer associated with this component in its decode method; ValueChangeEvent events by the component's validate method. In either case the event's source property references a component. At some later time the UIViewRoot component iterates over its queued events and invokes the broadcast method on each event's source object.

Overrides:
broadcast in class UIComponentBase
Parameters:
event - must not be null.
Throws:
AbortProcessingException

queueEvent

public void queueEvent(FacesEvent event)
Overrides:
queueEvent in class UIComponentBase

isImmediate

public boolean isImmediate()
Gets A boolean value that identifies the phase during which action events should fire. During normal event processing, action methods and action listener methods are fired during the "invoke application" phase of request processing. If this attribute is set to "true", these methods are fired instead at the end of the "apply request values" phase.

Specified by:
isImmediate in interface ActionSource
Returns:
the new immediate value

setImmediate

public void setImmediate(boolean immediate)
Sets A boolean value that identifies the phase during which action events should fire. During normal event processing, action methods and action listener methods are fired during the "invoke application" phase of request processing. If this attribute is set to "true", these methods are fired instead at the end of the "apply request values" phase.

Specified by:
setImmediate in interface ActionSource
Parameters:
immediate - the new immediate value

getValue

public java.lang.Object getValue()
Gets The initial value of this component.

Returns:
the new value value

setValue

public void setValue(java.lang.Object value)
Sets The initial value of this component.

Parameters:
value - the new value value

getActionExpression

public javax.el.MethodExpression getActionExpression()
Gets Specifies the action to take when this command is invoked. If the value is an expression, it is expected to be a method binding EL expression that identifies an action method. An action method accepts no parameters and has a String return value, called the action outcome, that identifies the next view displayed. The phase that this event is fired in can be controlled via the immediate attribute. If the value is a string literal, it is treated as a navigation outcome for the current view. This is functionally equivalent to a reference to an action method that returns the string literal.

Specified by:
getActionExpression in interface ActionSource2
Returns:
the new actionExpression value

setActionExpression

public void setActionExpression(javax.el.MethodExpression actionExpression)
Sets Specifies the action to take when this command is invoked. If the value is an expression, it is expected to be a method binding EL expression that identifies an action method. An action method accepts no parameters and has a String return value, called the action outcome, that identifies the next view displayed. The phase that this event is fired in can be controlled via the immediate attribute. If the value is a string literal, it is treated as a navigation outcome for the current view. This is functionally equivalent to a reference to an action method that returns the string literal.

Specified by:
setActionExpression in interface ActionSource2
Parameters:
actionExpression - the new actionExpression value

getActionListener

public MethodBinding getActionListener()
Deprecated. 

Gets A method binding EL expression that identifies an action listener method to be invoked if this component is activated by the user. An action listener method accepts a parameter of type javax.faces.event.ActionEvent and returns void. The phase that this event is fired in can be controlled via the immediate attribute.

Specified by:
getActionListener in interface ActionSource
Returns:
the new actionListener value

setActionListener

public void setActionListener(MethodBinding actionListener)
Deprecated. 

Sets A method binding EL expression that identifies an action listener method to be invoked if this component is activated by the user. An action listener method accepts a parameter of type javax.faces.event.ActionEvent and returns void. The phase that this event is fired in can be controlled via the immediate attribute.

Specified by:
setActionListener in interface ActionSource
Parameters:
actionListener - the new actionListener value

addActionListener

public void addActionListener(ActionListener listener)
Adds a action listener.

Specified by:
addActionListener in interface ActionSource
Parameters:
listener - the action listener to add

removeActionListener

public void removeActionListener(ActionListener listener)
Removes a action listener.

Specified by:
removeActionListener in interface ActionSource
Parameters:
listener - the action listener to remove

getActionListeners

public ActionListener[] getActionListeners()
Returns an array of attached action listeners.

Specified by:
getActionListeners in interface ActionSource
Returns:
an array of attached action listeners.

saveState

public java.lang.Object saveState(FacesContext facesContext)
Description copied from class: UIComponentBase
Invoked after the render phase has completed, this method returns an object which can be passed to the restoreState of some other instance of UIComponentBase to reset that object's state to the same values as this object currently has.

Specified by:
saveState in interface StateHolder
Overrides:
saveState in class UIComponentBase

restoreState

public void restoreState(FacesContext facesContext,
                         java.lang.Object state)
Description copied from class: UIComponentBase
Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into the provided state object.

Specified by:
restoreState in interface StateHolder
Overrides:
restoreState in class UIComponentBase
state - is an object previously returned by the saveState method of this class.

getFamily

public java.lang.String getFamily()
Specified by:
getFamily in class UIComponent


Copyright © 2010 Apache Software Foundation. All Rights Reserved.