javax.faces.component
Class UIComponent

java.lang.Object
  |
  +--javax.faces.component.UIComponent
All Implemented Interfaces:
StateHolder
Direct Known Subclasses:
UIComponentBase

public abstract class UIComponent
extends java.lang.Object
implements StateHolder

UIComponent is the base class for all user interface components in JavaServer Faces. The set of UIComponent instances associated with a particular request and response are organized into a component tree under a UIViewRoot that represents the entire content of the request or response.

For the convenience of component developers, UIComponentBase provides the default behavior that is specified for a UIComponent, and is the base class for all of the concrete UIComponent "base" implementations. Component writers are encouraged to subclass UIComponentBase, instead of directly implementing this abstract class, to reduce the impact of any future changes to the method signatures.


Constructor Summary
UIComponent()
           
 
Method Summary
protected abstract  void addFacesListener(javax.faces.event.FacesListener listener)
          Add the specified FacesListener to the set of listeners registered to receive event notifications from this UIComponent.
abstract  void broadcast(javax.faces.event.FacesEvent event)
          Broadcast the specified FacesEvent to all registered event listeners who have expressed an interest in events of this type.
abstract  void decode(javax.faces.context.FacesContext context)
          Decode any new state of this UIComponent from the request contained in the specified FacesContext, and store this state as needed.
abstract  void encodeBegin(javax.faces.context.FacesContext context)
          If our rendered property is true, render the beginning of the current state of this UIComponent to the response contained in the specified FacesContext.
abstract  void encodeChildren(javax.faces.context.FacesContext context)
          If our rendered property is true, render the child UIComponents of this UIComponent.
abstract  void encodeEnd(javax.faces.context.FacesContext context)
          If our rendered property is true, render the ending of the current state of this UIComponent.
abstract  javax.faces.component.UIComponent findComponent(java.lang.String expr)
          Search for and return the UIComponent with an id that matches the specified search expression (if any), according to the algorithm described below.
abstract  java.util.Map getAttributes()
          Return a mutable Map representing the attributes (and properties, see below) associated wth this UIComponent, keyed by attribute name (which must be a String).
abstract  int getChildCount()
          Return the number of child UIComponents that are associated with this UIComponent.
abstract  java.util.List getChildren()
          Return a mutable List representing the child UIComponents associated with this component.
abstract  java.lang.String getClientId(javax.faces.context.FacesContext context)
          Return a client-side identifier for this component, generating one if necessary.
protected abstract  javax.faces.context.FacesContext getFacesContext()
          Convenience method to return the FacesContext instance for the current request.
protected abstract  javax.faces.event.FacesListener[] getFacesListeners(java.lang.Class clazz)
          Return an array of registered FacesListeners that are instances of the specified class.
abstract  javax.faces.component.UIComponent getFacet(java.lang.String name)
          Convenience method to return the named facet, if it exists, or null otherwise.
abstract  java.util.Map getFacets()
          Return a mutable Map representing the facet UIComponents associated with this UIComponent, keyed by facet name (which must be a String).
abstract  java.util.Iterator getFacetsAndChildren()
          Return an Iterator over the facet followed by child UIComponents of this UIComponent.
abstract  java.lang.String getFamily()
          Return the identifier of the component family to which this component belongs.
abstract  java.lang.String getId()
          Return the component identifier of this UIComponent.
abstract  javax.faces.component.UIComponent getParent()
          Return the parent UIComponent of this UIComponent, if any.
protected abstract  javax.faces.render.Renderer getRenderer(javax.faces.context.FacesContext context)
          Convenience method to return the Renderer instance associated with this component, if any; otherwise, return null.
abstract  java.lang.String getRendererType()
          Return the Renderer type for this UIComponent (if any).
abstract  boolean getRendersChildren()
          Return a flag indicating whether this component is responsible for rendering its child components.
abstract  javax.faces.el.ValueBinding getValueBinding(java.lang.String name)
          Return the ValueBinding used to calculate the value for the specified attribute or property name, if any.
abstract  boolean isRendered()
          Return true if this component (and its children) should be rendered during the Render Response phase of the request processing lifecycle.
abstract  void processDecodes(javax.faces.context.FacesContext context)
          Perform the component tree processing required by the Apply Request Values phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
abstract  void processRestoreState(javax.faces.context.FacesContext context, java.lang.Object state)
          Perform the component tree processing required by the Restore View phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
abstract  java.lang.Object processSaveState(javax.faces.context.FacesContext context)
          Perform the component tree processing required by the state saving portion of the Render Response phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
abstract  void processUpdates(javax.faces.context.FacesContext context)
          Perform the component tree processing required by the Update Model Values phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
abstract  void processValidators(javax.faces.context.FacesContext context)
          Perform the component tree processing required by the Process Validations phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
abstract  void queueEvent(javax.faces.event.FacesEvent event)
          Queue an event for broadcast at the end of the current request processing lifecycle phase.
protected abstract  void removeFacesListener(javax.faces.event.FacesListener listener)
          Remove the specified FacesListener from the set of listeners registered to receive event notifications from this UIComponent.
abstract  void setId(java.lang.String id)
          Set the component identifier of this UIComponent (if any).
abstract  void setParent(javax.faces.component.UIComponent parent)
          Set the parent UIComponent of this UIComponent.
abstract  void setRendered(boolean rendered)
          Set the rendered property of this UIComponent.
abstract  void setRendererType(java.lang.String rendererType)
          Set the Renderer type for this UIComponent, or null for components that render themselves.
abstract  void setValueBinding(java.lang.String name, javax.faces.el.ValueBinding binding)
          Set the ValueBinding used to calculate the value for the specified attribute or property name, if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.StateHolder
isTransient, restoreState, saveState, setTransient
 

Constructor Detail

UIComponent

public UIComponent()
Method Detail

getAttributes

public abstract java.util.Map getAttributes()

Return a mutable Map representing the attributes (and properties, see below) associated wth this UIComponent, keyed by attribute name (which must be a String). The returned implementation must support all of the standard and optional Map methods, plus support the following additional requirements:


getValueBinding

public abstract javax.faces.el.ValueBinding getValueBinding(java.lang.String name)

Return the ValueBinding used to calculate the value for the specified attribute or property name, if any.

Parameters:
name - Name of the attribute or property for which to retrieve a ValueBinding
Throws:
java.lang.NullPointerException - if name is null

setValueBinding

public abstract void setValueBinding(java.lang.String name,
                                     javax.faces.el.ValueBinding binding)

Set the ValueBinding used to calculate the value for the specified attribute or property name, if any.

Parameters:
name - Name of the attribute or property for which to set a ValueBinding
binding - The ValueBinding to set, or null to remove any currently set ValueBinding
Throws:
java.lang.IllegalArgumentException - if name is one of id or parent
java.lang.NullPointerException - if name is null

getClientId

public abstract java.lang.String getClientId(javax.faces.context.FacesContext context)

Return a client-side identifier for this component, generating one if necessary. The associated Renderer, if any, will be asked to convert the clientId to a form suitable for transmission to the client.

The return from this method must be the same value throughout the lifetime of the instance, unless the id property of the component is changed, or the component is placed in a NamingContainer whose client ID changes (for example, UIData). However, even in these cases, consecutive calls to this method must always return the same value.

Parameters:
context - The FacesContext for the current request
Throws:
java.lang.NullPointerException - if context is null

getFamily

public abstract java.lang.String getFamily()

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 appropriate Renderer for this component instance.


getId

public abstract java.lang.String getId()

Return the component identifier of this UIComponent.


setId

public abstract void setId(java.lang.String id)

Set the component identifier of this UIComponent (if any). Component identifiers must obey the following syntax restrictions:

Component identifiers must also obey the following semantic restrictions (note that this restriction is NOT enforced by the setId() implementation):

Parameters:
id - The new component identifier, or null to indicate that this UIComponent does not have a component identifier
Throws:
java.lang.IllegalArgumentException - if id is not syntactically valid

getParent

public abstract javax.faces.component.UIComponent getParent()

Return the parent UIComponent of this UIComponent, if any.


setParent

public abstract void setParent(javax.faces.component.UIComponent parent)

Set the parent UIComponent of this UIComponent. This method must never be called by developers; a UIComponent's internal implementation will call it as components are added to or removed from a parent's child List or facet Map.

Parameters:
parent - The new parent, or null for the root node of a component tree

isRendered

public abstract boolean isRendered()

Return true if this component (and its children) should be rendered during the Render Response phase of the request processing lifecycle.


setRendered

public abstract void setRendered(boolean rendered)

Set the rendered property of this UIComponent.

Parameters:
rendered - If true render this component; otherwise, do not render this component

getRendererType

public abstract java.lang.String getRendererType()

Return the Renderer type for this UIComponent (if any).


setRendererType

public abstract void setRendererType(java.lang.String rendererType)

Set the Renderer type for this UIComponent, or null for components that render themselves.

Parameters:
rendererType - Logical identifier of the type of Renderer to use, or null for components that render themselves

getRendersChildren

public abstract boolean getRendersChildren()

Return a flag indicating whether this component is responsible for rendering its child components. The default implementation in UIComponentBase.getRendersChildren() tries to find the renderer for this component. If it does, it calls Renderer.getRendersChildren() and returns the result. If it doesn't, it returns false.


getChildren

public abstract java.util.List getChildren()

Return a mutable List representing the child UIComponents associated with this component. The returned implementation must support all of the standard and optional List methods, plus support the following additional requirements:


getChildCount

public abstract int getChildCount()

Return the number of child UIComponents that are associated with this UIComponent. If there are no children, this method must return 0. The method must not cause the creation of a child component list.


findComponent

public abstract javax.faces.component.UIComponent findComponent(java.lang.String expr)

Search for and return the UIComponent with an id that matches the specified search expression (if any), according to the algorithm described below.

Component identifiers are required to be unique within the scope of the closest ancestor NamingContainer that encloses this component (which might be this component itself). If there are no NamingContainer components in the ancestry of this component, the root component in the tree is treated as if it were a NamingContainer, whether or not its class actually implements the NamingContainer interface.

A search expression consists of either an identifier (which is matched exactly against the id property of a UIComponent, or a series of such identifiers linked by the NamingContainer.SEPARATOR_CHAR character value. The search algorithm operates as follows:

Parameters:
expr - Search expression identifying the UIComponent to be returned
Returns:
the found UIComponent, or null if the component was not found.
Throws:
java.lang.IllegalArgumentException - if an intermediate identifier in a search expression identifies a UIComponent that is not a NamingContainer
java.lang.NullPointerException - if expr is null

getFacets

public abstract java.util.Map getFacets()

Return a mutable Map representing the facet UIComponents associated with this UIComponent, keyed by facet name (which must be a String). The returned implementation must support all of the standard and optional Map methods, plus support the following additional requirements:


getFacet

public abstract javax.faces.component.UIComponent getFacet(java.lang.String name)

Convenience method to return the named facet, if it exists, or null otherwise. If the requested facet does not exist, the facets Map must not be created.

Parameters:
name - Name of the desired facet

getFacetsAndChildren

public abstract java.util.Iterator getFacetsAndChildren()

Return an Iterator over the facet followed by child UIComponents of this UIComponent. Facets are returned in an undefined order, followed by all the children in the order they are stored in the child list. If this component has no facets or children, an empty Iterator is returned.

The returned Iterator must not support the remove() operation.


broadcast

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

Broadcast the specified FacesEvent to all registered event listeners who have expressed an interest in events of this type. Listeners are called in the order in which they were added.

Parameters:
event - The FacesEvent to be broadcast
Throws:
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

decode

public abstract void decode(javax.faces.context.FacesContext context)

Decode any new state of this UIComponent from the request contained in the specified FacesContext, and store this state as needed.

During decoding, events may be enqueued for later processing (by event listeners who have registered an interest), by calling queueEvent().

Parameters:
context - FacesContext for the request we are processing
Throws:
java.lang.NullPointerException - if context is null

encodeBegin

public abstract void encodeBegin(javax.faces.context.FacesContext context)
                          throws java.io.IOException

If our rendered property is true, render the beginning of the current state of this UIComponent to the response contained in the specified FacesContext.

If a Renderer is associated with this UIComponent, the actual encoding will be delegated to Renderer.encodeBegin(FacesContext, UIComponent).

Parameters:
context - FacesContext for the response we are creating
Throws:
java.io.IOException - if an input/output error occurs while rendering
java.lang.NullPointerException - if context is null

encodeChildren

public abstract void encodeChildren(javax.faces.context.FacesContext context)
                             throws java.io.IOException

If our rendered property is true, render the child UIComponents of this UIComponent. This method will only be called if the rendersChildren property is true.

If a Renderer is associated with this UIComponent, the actual encoding will be delegated to Renderer.encodeBegin(FacesContext, UIComponent).

Parameters:
context - FacesContext for the response we are creating
Throws:
java.io.IOException - if an input/output error occurs while rendering
java.lang.NullPointerException - if context is null

encodeEnd

public abstract void encodeEnd(javax.faces.context.FacesContext context)
                        throws java.io.IOException

If our rendered property is true, render the ending of the current state of this UIComponent.

If a Renderer is associated with this UIComponent, the actual encoding will be delegated to Renderer.encodeBegin(FacesContext, UIComponent).

Parameters:
context - FacesContext for the response we are creating
Throws:
java.io.IOException - if an input/output error occurs while rendering
java.lang.NullPointerException - if context is null

addFacesListener

protected abstract void addFacesListener(javax.faces.event.FacesListener listener)

Add the specified FacesListener to the set of listeners registered to receive event notifications from this UIComponent. It is expected that UIComponent classes acting as event sources will have corresponding typesafe APIs for registering listeners of the required type, and the implementation of those registration methods will delegate to this method. For example:

 public class FooEvent extends FacesEvent { ... }

 public interface FooListener extends FacesListener {
   public void processFoo(FooEvent event);
 }

 public class FooComponent extends UIComponentBase {
   ...
   public void addFooListener(FooListener listener) {
     addFacesListener(listener);
   }
   public void removeFooListener(FooListener listener) {
     removeFacesListener(listener);
   }
   ...
 }
 

Parameters:
listener - The FacesListener to be registered
Throws:
java.lang.NullPointerException - if listener is null

getFacesListeners

protected abstract javax.faces.event.FacesListener[] getFacesListeners(java.lang.Class clazz)

Return an array of registered FacesListeners that are instances of the specified class. If there are no such registered listeners, a zero-length array is returned. The returned array can be safely be cast to an array strongly typed to an element type of clazz.

Parameters:
clazz - Class that must be implemented by a FacesListener for it to be returned
Throws:
java.lang.IllegalArgumentException - if class is not, and does not implement, FacesListener
java.lang.NullPointerException - if clazz is null

removeFacesListener

protected abstract void removeFacesListener(javax.faces.event.FacesListener listener)

Remove the specified FacesListener from the set of listeners registered to receive event notifications from this UIComponent.

Parameters:
listener - The FacesListener to be deregistered
Throws:
java.lang.NullPointerException - if listener is null

queueEvent

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

Queue an event for broadcast at the end of the current request processing lifecycle phase. The default implementation in UIComponentBase must delegate this call to the queueEvent() method of the parent UIComponent.

Parameters:
event - FacesEvent to be queued
Throws:
java.lang.IllegalStateException - if this component is not a descendant of a UIViewRoot
java.lang.NullPointerException - if event is null

processRestoreState

public abstract void processRestoreState(javax.faces.context.FacesContext context,
                                         java.lang.Object state)

Perform the component tree processing required by the Restore View phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.

This method may not be called if the state saving method is set to server.

Parameters:
context - FacesContext for the request we are processing
Throws:
java.lang.NullPointerException - if context is null

processDecodes

public abstract void processDecodes(javax.faces.context.FacesContext context)

Perform the component tree processing required by the Apply Request Values phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.

Parameters:
context - FacesContext for the request we are processing
Throws:
java.lang.NullPointerException - if context is null

processValidators

public abstract void processValidators(javax.faces.context.FacesContext context)

Perform the component tree processing required by the Process Validations phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.

Parameters:
context - FacesContext for the request we are processing
Throws:
java.lang.NullPointerException - if context is null

processUpdates

public abstract void processUpdates(javax.faces.context.FacesContext context)

Perform the component tree processing required by the Update Model Values phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.

Parameters:
context - FacesContext for the request we are processing
Throws:
java.lang.NullPointerException - if context is null

processSaveState

public abstract java.lang.Object processSaveState(javax.faces.context.FacesContext context)

Perform the component tree processing required by the state saving portion of the Render Response phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.

This method may not be called if the state saving method is set to server.

Parameters:
context - FacesContext for the request we are processing
Throws:
java.lang.NullPointerException - if context is null

getFacesContext

protected abstract javax.faces.context.FacesContext getFacesContext()

Convenience method to return the FacesContext instance for the current request.


getRenderer

protected abstract javax.faces.render.Renderer getRenderer(javax.faces.context.FacesContext context)

Convenience method to return the Renderer instance associated with this component, if any; otherwise, return null.

Parameters:
context - FacesContext for the current request


Copyright ? 2002-2004 Sun Microsystems, Inc. All Rights Reserved.