com.sun.webui.jsf.component
Class EventSourceImpl

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by com.sun.webui.jsf.component.EventSourceImpl
All Implemented Interfaces:
EventSource, javax.faces.component.StateHolder
Direct Known Subclasses:
Menu

public abstract class EventSourceImpl
extends javax.faces.component.UIComponentBase
implements EventSource

The EventSource interface defines a minimal component interface to provide an application with simple GUI events. These GUI events reflect "gestures" made by the user, such as selecting a menu option, or any action that results in a reqeust value representing that action submitted in a request either by "form.submit" or an XmlHttpRequest. The intention is that specific event components will implement this interface and define their own subclass of FacesEvents. A typical event would include the appropriate phase in which the event should be broadcast, the EventSource component as the source of the event and the event payload which will be the converted request value. For example, a Menu component would implement EventSource and when a Menu gesture is seen in the request, will queue an appropriate event, with the component instance as the source and the result of calling "getConvertedValue" either implemented in the renderer or the component as the Event payload. It is this payload that the application can inspect to indicate the Menu "selection" and act accordingly. In addition EventSource can be implemented to support the navigational features of an ActionSource.


Constructor Summary
EventSourceImpl()
           
 
Method Summary
 void addEventListener(com.sun.webui.jsf.event.EventListener listener)
          Add a new EventListener to the set of listeners interested in being notified when EventSourceevents s occur.
 void broadcast(javax.faces.event.FacesEvent event)
          In addition to to the default UIComponent.broadcast(javax.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.
 javax.el.MethodExpression getEventExpression()
          Return the MethodExpression pointing at the application action to be invoked, if this UIComponent is activated by the user, during PhaseId.ANY in case of immediate or PhaseId.INVOKE_APPLICATION phase by default, or the specific phase as set on the event of the request processing lifecycle,
 javax.el.MethodExpression getEventListenerExpression()
          Used to specify a method to handle an menu event that is triggered when this component is activated by the user.
 com.sun.webui.jsf.event.EventListener[] getEventListeners()
          Return the set of registered EventListeners for this EventSource instance.
 javax.faces.event.PhaseId getPhaseId()
          Return the PhaseId of the lifecycle phase in which events will be queued.
 boolean isImmediate()
          Return a flag indicating that this event should be broadcast at the next available opportunity, ususally between lifecycle phases i.e.
 void processEventExpression()
           
 void queueEvent(javax.faces.event.FacesEvent e)
          Intercept queueEvent and, for ActionEvents, mark the phaseId for the event to be PhaseId.APPLY_REQUEST_VALUES if the immediate flag is true, PhaseId.INVOKE_APPLICATION otherwise.
 void removeEventListener(com.sun.webui.jsf.event.EventListener listener)
          Remove an existing EventListener (if any) from the set of listeners interested in being notified when EventSource events occur.
 void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext _context)
          Save the state of this component.
 void setEventExpression(javax.el.MethodExpression eventExpression)
          Set the MethodExpression pointing at the application action to be invoked, if this UIComponent is activated by the user, during PhaseId.ANY in case of immediate or PhaseId.INVOKE_APPLICATION phase by default, or the specific phase as set on the event of the request processing lifecycle,
 void setEventListenerExpression(javax.el.MethodExpression me)
          Used to specify a method to handle an menu event that is triggered when this component is activated by the user.
 void setImmediate(boolean immediate)
          Set the "immediate execution" flag for this UIComponent.
 void setPhaseId(javax.faces.event.PhaseId phaseId)
          Set the PhaseId in which events should be broadcast.
 
Methods inherited from class javax.faces.component.UIComponentBase
decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendererType, getRendersChildren, getValueBinding, getValueExpression, invokeOnComponent, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, setValueExpression
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId, getFamily
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventSourceImpl

public EventSourceImpl()
Method Detail

isImmediate

public boolean isImmediate()
Return a flag indicating that this event should be broadcast at the next available opportunity, ususally between lifecycle phases i.e. PhaseId.ANY.

Specified by:
isImmediate in interface EventSource

setImmediate

public void setImmediate(boolean immediate)

Set the "immediate execution" flag for this UIComponent.

Specified by:
setImmediate in interface EventSource
Parameters:
immediate - The new immediate execution flag

getEventExpression

public javax.el.MethodExpression getEventExpression()
Return the MethodExpression pointing at the application action to be invoked, if this UIComponent is activated by the user, during PhaseId.ANY in case of immediate or PhaseId.INVOKE_APPLICATION phase by default, or the specific phase as set on the event of the request processing lifecycle,

Specified by:
getEventExpression in interface EventSource

setEventExpression

public void setEventExpression(javax.el.MethodExpression eventExpression)

Set the MethodExpression pointing at the application action to be invoked, if this UIComponent is activated by the user, during PhaseId.ANY in case of immediate or PhaseId.INVOKE_APPLICATION phase by default, or the specific phase as set on the event of the request processing lifecycle,

Any method referenced by such an expression must be public, with a return type of String, and accept no parameters.

Specified by:
setEventExpression in interface EventSource
Parameters:
eventExpression - The new method expression

addEventListener

public void addEventListener(com.sun.webui.jsf.event.EventListener listener)

Add a new EventListener to the set of listeners interested in being notified when EventSourceevents s occur.

Specified by:
addEventListener in interface EventSource
Parameters:
listener - The EventListener to be added
Throws:
java.lang.NullPointerException - if listener is null

getEventListeners

public com.sun.webui.jsf.event.EventListener[] getEventListeners()

Return the set of registered EventListeners for this EventSource instance. If there are no registered listeners, a zero-length array is returned.

Specified by:
getEventListeners in interface EventSource

getEventListenerExpression

public javax.el.MethodExpression getEventListenerExpression()

Used to specify a method to handle an menu event that is triggered when this component is activated by the user. Value must be a JavaServer Faces EL expression that resolves to a method in a backing bean. The method must take a single parameter that is an event, and its return type must be void. The class that defines the method must implement the java.io.Serializable interface or javax.faces.component.StateHolder interface.


setEventListenerExpression

public void setEventListenerExpression(javax.el.MethodExpression me)

Used to specify a method to handle an menu event that is triggered when this component is activated by the user. Value must be a JavaServer Faces EL expression that resolves to a method in a backing bean. The method must take a single parameter that is an event, and its return type must be void. The class that defines the method must implement the java.io.Serializable interface or javax.faces.component.StateHolder interface.


removeEventListener

public void removeEventListener(com.sun.webui.jsf.event.EventListener listener)

Remove an existing EventListener (if any) from the set of listeners interested in being notified when EventSource events occur.

Specified by:
removeEventListener in interface EventSource
Parameters:
listener - The EventListener to be removed
Throws:
java.lang.NullPointerException - if listener is null

processEventExpression

public void processEventExpression()

broadcast

public void broadcast(javax.faces.event.FacesEvent event)
               throws javax.faces.event.AbortProcessingException

In addition to to the default UIComponent.broadcast(javax.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.

Overrides:
broadcast in class javax.faces.component.UIComponentBase
Parameters:
event - FacesEvent to be broadcast
Throws:
javax.faces.event.AbortProcessingException - Signal the JavaServer Faces implementation that no further processing on the current event should be performed
java.lang.IllegalArgumentException - if the implementation class of this FacesEvent is not supported by this component
java.lang.NullPointerException - if event is null

setPhaseId

public void setPhaseId(javax.faces.event.PhaseId phaseId)
Set the PhaseId in which events should be broadcast. The default is PhaseId.INVOKE_APPLICATION or PhaseId.ANY if isImmediate returns true


getPhaseId

public javax.faces.event.PhaseId getPhaseId()
Return the PhaseId of the lifecycle phase in which events will be queued.


queueEvent

public void queueEvent(javax.faces.event.FacesEvent e)

Intercept queueEvent and, for ActionEvents, mark the phaseId for the event to be PhaseId.APPLY_REQUEST_VALUES if the immediate flag is true, PhaseId.INVOKE_APPLICATION otherwise.

Overrides:
queueEvent in class javax.faces.component.UIComponentBase

restoreState

public void restoreState(javax.faces.context.FacesContext _context,
                         java.lang.Object _state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext _context)

Save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.component.UIComponentBase


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.