javax.faces.component
Class UIComponentBase

java.lang.Object
  extended byjavax.faces.component.UIComponentBase
All Implemented Interfaces:
java.io.Serializable, UIComponent
Direct Known Subclasses:
UICommand, UIForm, UINamingContainer, UIOutput

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

UIComponentBase is a convenience base class that implements the default concrete behavior of all methods defined by UIComponent.

By default, this class defines getRendersChildren() to return false. Subclasses that wish to manage the rendering of their children should override this method to return true instead.

By default, this class defines getRendersSelf() to return false. Subclasses that have directly implemented decoding and encoding functionality, without the requirement for an associated Renderer, should override this method to return true instead.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface javax.faces.component.UIComponent
SEPARATOR_CHAR
 
Constructor Summary
UIComponentBase()
           
 
Method Summary
 void addChild(int index, UIComponent component)
          Insert the specified UIComponent at the specified position in the child list for this component.
 void addChild(UIComponent component)
          Append the specified UIComponent to the end of the child list for this component.
 void addFacet(java.lang.String facetName, UIComponent facet)
          Add the specified UIComponent as a facet associated with the name specified by the facetName argument, replacing any previous facet with that name.
 void addValidator(Validator validator)
          Add a Validator instance to the set associated with this UIComponent.
 boolean broadcast(FacesEvent event, PhaseId phaseId)
          Broadcast the specified FacesEvent to all registered event listeners who have expressed an interest in events of this type, for the specified PhaseId (or for any phase, if the listener returns PhaseId.ANY_PHASE from its getPhaseId() method.
 void clearChildren()
          Remove all child UIComponents from the child list.
 void clearFacets()
          Remove all facet UIComponents from this component.
 void clearValidators()
          Clear any Validators that have been registered for processing by this component.
 boolean containsChild(UIComponent component)
          Return true if the specified UIComponent is a direct child of this UIComponent; otherwise, return false.
 void decode(FacesContext context)
          Decode the current state of this UIComponent from the request contained in the specified FacesContext, and attempt to convert this state information into an object of the required type for this component (optionally using the registered Converter for this component, if there is one.
 void encodeBegin(FacesContext context)
          Render the beginning of the current state of this UIComponent to the response contained in the specified FacesContext.
 void encodeChildren(FacesContext context)
          Render the child UIComponents of this UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered.
 void encodeEnd(FacesContext context)
          Render the ending of the current state of this UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered.
 UIComponent findComponent(java.lang.String expr)
          Find the UIComponent named by the specified expression, if any is found.
 java.lang.Object getAttribute(java.lang.String name)
          Return the value of the attribute with the specified name (if any); otherwise, return null.
 java.util.Iterator getAttributeNames()
          Return an Iterator over the names of all currently defined attributes of this UIComponent that have a non-null value.
 UIComponent getChild(int index)
          Return the UIComponent at the specified position in the child list for this component.
 int getChildCount()
          Return the number of UIComponents on the child list for this component.
 java.util.Iterator getChildren()
          Return an Iterator over the child UIComponents of this UIComponent, in the order of their position in the child list.
 java.lang.String getClientId(FacesContext context)
          Return a client-side identifier for this component, generating one if necessary.
 java.lang.String getComponentId()
          Return the identifier of this UIComponent.
 java.lang.String getConverter()
          Return the converter id of the Converter that is registered for this component.
 UIComponent getFacet(java.lang.String name)
          Return the facet UIComponent associated with the specified name, if any.
 java.util.Iterator getFacetNames()
          Return an Iterator over the names of the facet UIComponents of this UIComponent.
 java.util.Iterator getFacetsAndChildren()
          Return an Iterator over the facet followed by child UIComponents of this UIComponent.
 UIComponent getParent()
          Return the parent UIComponent of this UIComponent, if any.
 java.lang.String getRendererType()
          Return the Renderer type for this UIComponent (if any).
 boolean getRendersChildren()
          Return a flag indicating whether this component is responsible for rendering its child components.
 boolean getRendersSelf()
          Return a flag indicating whether this component has concrete implementations of the decode() and encodeXxx() methods, and is therefore suitable for use in the direct implementation programming model for rendering.
 java.util.Iterator getValidators()
          Return an Iterator over the Validators associated with this UIComponent.
 boolean isRendered()
          Return true if this component (and its children) should be rendered during the Render Response phase of the request processing lifecycle.
 boolean isValid()
          Return the current validity state of this component.
 void processDecodes(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.
 void processReconstitutes(FacesContext context)
          Perform the component tree processing required by the Reconstitute Component Tree phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
 void processUpdates(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.
 void processValidators(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.
 void reconstitute(FacesContext context)
          Perform any processing required to correct the state of this component as a result of the owning component tree having been reconstructed during Reconstitute Component Tree phase of the request processing lifecycle.
 void removeChild(int index)
          Remove the child UIComponent at the specified position in the child list for this component.
 void removeChild(UIComponent component)
          Remove the child UIComponent from the child list for this component.
 void removeFacet(java.lang.String name)
          Remove the facet UIComponent associated with the specified name, if there is one.
 void removeValidator(Validator validator)
          Remove a Validator instance from the set associated with this UIComponent, if it was previously associated.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set the new value of the attribute with the specified name, replacing any existing value for that name.
 void setComponentId(java.lang.String componentId)
          Set the identifier of this UIComponent.
 void setConverter(java.lang.String converter)
          Set the converter id of the Converter that is registered for this component, or null to indicate that there is no registered Converter.
 void setParent(UIComponent parent)
          Set the parent UIComponent of this UIComponent.
 void setRendered(boolean rendered)
          Set the rendered property of this UIComponent.
 void setRendererType(java.lang.String rendererType)
          Set the Renderer type for this UIComponent, or null for components that render themselves.
 void setValid(boolean valid)
          Set the current validity state of this component.
 void updateModel(FacesContext context)
          Update the model data associated with this UIComponent, if any.
 void validate(FacesContext context)
          Perform any correctness checks that this component wishes to perform on itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIComponentBase

public UIComponentBase()
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface: UIComponent

Return the value of the attribute with the specified name (if any); otherwise, return null.

Specified by:
getAttribute in interface UIComponent
Parameters:
name - Name of the requested attribute

getAttributeNames

public java.util.Iterator getAttributeNames()
Description copied from interface: UIComponent

Return an Iterator over the names of all currently defined attributes of this UIComponent that have a non-null value.

Specified by:
getAttributeNames in interface UIComponent

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Description copied from interface: UIComponent

Set the new value of the attribute with the specified name, replacing any existing value for that name.

Specified by:
setAttribute in interface UIComponent
Parameters:
name - Name of the requested attribute
value - New value (or null to remove any attribute value for the specified name

getClientId

public java.lang.String getClientId(FacesContext context)
Description copied from interface: UIComponent

Return a client-side identifier for this component, generating one if necessary. Generation will be delegated to the associated Renderer (if there is one).

Specified by:
getClientId in interface UIComponent
Parameters:
context - The FacesContext for the current request

getComponentId

public java.lang.String getComponentId()
Description copied from interface: UIComponent

Return the identifier of this UIComponent.

Specified by:
getComponentId in interface UIComponent

setComponentId

public void setComponentId(java.lang.String componentId)
Description copied from interface: UIComponent

Set the identifier of this UIComponent.

Specified by:
setComponentId in interface UIComponent
Parameters:
componentId - The new identifier

getConverter

public java.lang.String getConverter()
Description copied from interface: UIComponent

Return the converter id of the Converter that is registered for this component.

Specified by:
getConverter in interface UIComponent

setConverter

public void setConverter(java.lang.String converter)
Description copied from interface: UIComponent

Set the converter id of the Converter that is registered for this component, or null to indicate that there is no registered Converter.

Specified by:
setConverter in interface UIComponent
Parameters:
converter - New converter identifier (or null)

getParent

public UIComponent getParent()
Description copied from interface: UIComponent

Return the parent UIComponent of this UIComponent, if any.

Specified by:
getParent in interface UIComponent

setParent

public void setParent(UIComponent parent)
Description copied from interface: UIComponent

Set the parent UIComponent of this UIComponent.

Specified by:
setParent in interface UIComponent
Parameters:
parent - The new parent, or null for the root node of a component tree

isRendered

public boolean isRendered()
Description copied from interface: UIComponent

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

Specified by:
isRendered in interface UIComponent

setRendered

public void setRendered(boolean rendered)
Description copied from interface: UIComponent

Set the rendered property of this UIComponent.

Specified by:
setRendered in interface UIComponent
Parameters:
rendered - If true render this component; otherwise, do not render this component

getRendererType

public java.lang.String getRendererType()
Description copied from interface: UIComponent

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

Specified by:
getRendererType in interface UIComponent

setRendererType

public void setRendererType(java.lang.String rendererType)
Description copied from interface: UIComponent

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

Specified by:
setRendererType in interface UIComponent
Parameters:
rendererType - Logical identifier of the type of Renderer to use, or null for components that render themselves

getRendersChildren

public boolean getRendersChildren()
Description copied from interface: UIComponent

Return a flag indicating whether this component is responsible for rendering its child components.

Specified by:
getRendersChildren in interface UIComponent

getRendersSelf

public boolean getRendersSelf()
Description copied from interface: UIComponent

Return a flag indicating whether this component has concrete implementations of the decode() and encodeXxx() methods, and is therefore suitable for use in the direct implementation programming model for rendering.

Specified by:
getRendersSelf in interface UIComponent

isValid

public boolean isValid()
Description copied from interface: UIComponent

Return the current validity state of this component. The validity state of a component is adjusted at the following points during the request processing lifecycle:

Specified by:
isValid in interface UIComponent

setValid

public void setValid(boolean valid)
Description copied from interface: UIComponent

Set the current validity state of this component.

Specified by:
setValid in interface UIComponent
Parameters:
valid - The new validity state

addChild

public void addChild(UIComponent component)
Description copied from interface: UIComponent

Append the specified UIComponent to the end of the child list for this component.

If the child to be added has a non-null and valid component identifier, the identifier is added to the namespace of the closest ancestor that is a naming container.

It is valid for a component to have a null component identifier or a component identifier that is the empty string.

Specified by:
addChild in interface UIComponent
Parameters:
component - UIComponent to be added

addChild

public void addChild(int index,
                     UIComponent component)
Description copied from interface: UIComponent

Insert the specified UIComponent at the specified position in the child list for this component.

If the child to be added has a non-null and valid component identifier, the identifier is added to the namespace of the closest ancestor that is a naming container.

It is valid for a component to have a null component identifier or a component identifier that is the empty string.

Specified by:
addChild in interface UIComponent
Parameters:
index - Zero-relative index at which to add this UIComponent
component - The UIComponent to be added

clearChildren

public void clearChildren()
Description copied from interface: UIComponent

Remove all child UIComponents from the child list.

Specified by:
clearChildren in interface UIComponent

containsChild

public boolean containsChild(UIComponent component)
Description copied from interface: UIComponent

Return true if the specified UIComponent is a direct child of this UIComponent; otherwise, return false.

Specified by:
containsChild in interface UIComponent
Parameters:
component - UIComponent to be checked

findComponent

public UIComponent findComponent(java.lang.String expr)
Description copied from interface: UIComponent

Find the UIComponent named by the specified expression, if any is found. This is done by locating the closest parent UIComponent that is a NamingContainer, and calling its findComponentInNamespace() method.

The specified expr may contain either a component identifier, or a set of component identifiers separated by SEPARATOR_CHAR characters.

Specified by:
findComponent in interface UIComponent
Parameters:
expr - Expression identifying the UIComponent to be returned
Returns:
the found UIComponent, or null if the component was not found.

getChild

public UIComponent getChild(int index)
Description copied from interface: UIComponent

Return the UIComponent at the specified position in the child list for this component.

Specified by:
getChild in interface UIComponent
Parameters:
index - Position of the desired component

getChildCount

public int getChildCount()
Description copied from interface: UIComponent

Return the number of UIComponents on the child list for this component.

Specified by:
getChildCount in interface UIComponent

getChildren

public java.util.Iterator getChildren()
Description copied from interface: UIComponent

Return an Iterator over the child UIComponents of this UIComponent, in the order of their position in the child list. If this component has no children, an empty Iterator is returned.

Specified by:
getChildren in interface UIComponent

removeChild

public void removeChild(int index)
Description copied from interface: UIComponent

Remove the child UIComponent at the specified position in the child list for this component.

Specified by:
removeChild in interface UIComponent
Parameters:
index - Position of the component to be removed

removeChild

public void removeChild(UIComponent component)
Description copied from interface: UIComponent

Remove the child UIComponent from the child list for this component.

Specified by:
removeChild in interface UIComponent
Parameters:
component - Child component to be removed

addFacet

public void addFacet(java.lang.String facetName,
                     UIComponent facet)
Description copied from interface: UIComponent

Add the specified UIComponent as a facet associated with the name specified by the facetName argument, replacing any previous facet with that name. The newly added facet will have its parent property set to this component.

Specified by:
addFacet in interface UIComponent
Parameters:
facetName - The name of this facet
facet - The new facet UIComponent

clearFacets

public void clearFacets()
Description copied from interface: UIComponent

Remove all facet UIComponents from this component.

Specified by:
clearFacets in interface UIComponent

getFacet

public UIComponent getFacet(java.lang.String name)
Description copied from interface: UIComponent

Return the facet UIComponent associated with the specified name, if any. Otherwise, return null.

Specified by:
getFacet in interface UIComponent
Parameters:
name - Name of the facet to be retrieved

getFacetNames

public java.util.Iterator getFacetNames()
Description copied from interface: UIComponent

Return an Iterator over the names of the facet UIComponents of this UIComponent. If this component has no facets, an empty Iterator is returned.

Specified by:
getFacetNames in interface UIComponent

removeFacet

public void removeFacet(java.lang.String name)
Description copied from interface: UIComponent

Remove the facet UIComponent associated with the specified name, if there is one. The removed facet will have its parent property cleared.

Specified by:
removeFacet in interface UIComponent
Parameters:
name - Name of the facet to be removed

getFacetsAndChildren

public java.util.Iterator getFacetsAndChildren()
Description copied from interface: UIComponent

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.

Specified by:
getFacetsAndChildren in interface UIComponent

addValidator

public void addValidator(Validator validator)
Description copied from interface: UIComponent

Add a Validator instance to the set associated with this UIComponent.

Specified by:
addValidator in interface UIComponent
Parameters:
validator - The Validator to add

clearValidators

public void clearValidators()
Description copied from interface: UIComponent

Clear any Validators that have been registered for processing by this component.

Specified by:
clearValidators in interface UIComponent

getValidators

public java.util.Iterator getValidators()
Description copied from interface: UIComponent

Return an Iterator over the Validators associated with this UIComponent.

Specified by:
getValidators in interface UIComponent

removeValidator

public void removeValidator(Validator validator)
Description copied from interface: UIComponent

Remove a Validator instance from the set associated with this UIComponent, if it was previously associated. Otherwise, do nothing.

Specified by:
removeValidator in interface UIComponent
Parameters:
validator - The Validator to remove

broadcast

public boolean broadcast(FacesEvent event,
                         PhaseId phaseId)
                  throws AbortProcessingException
Description copied from interface: UIComponent

Broadcast the specified FacesEvent to all registered event listeners who have expressed an interest in events of this type, for the specified PhaseId (or for any phase, if the listener returns PhaseId.ANY_PHASE from its getPhaseId() method. The order in which registered listeners are notified is implementation dependent.

After all interested listeners have been notified, return false if this event does not have any listeners interested in this event in future phases of the request processing lifecycle. Otherwise, return true.

Specified by:
broadcast in interface UIComponent
Parameters:
event - The FacesEvent to be broadcast
phaseId - The PhaseId of the current phase of the request processing lifecycle
Throws:
AbortProcessingException - Signal the JavaServer Faces implementation that no further processing on the current event should be performed

decode

public void decode(FacesContext context)
            throws java.io.IOException
Description copied from interface: UIComponent

Decode the current state of this UIComponent from the request contained in the specified FacesContext, and attempt to convert this state information into an object of the required type for this component (optionally using the registered Converter for this component, if there is one.

If conversion is successful:

If conversion is not successful:

During decoding, events may be enqueued for later processing (by event listeners who have registered an interest), by calling addFacesEvent() on the associated FacesContext.

Specified by:
decode in interface UIComponent
Parameters:
context - FacesContext for the request we are processing
Throws:
java.io.IOException - if an input/output error occurs during decoding

encodeBegin

public void encodeBegin(FacesContext context)
                 throws java.io.IOException
Description copied from interface: UIComponent

Render the beginning of the current state of this UIComponent to the response contained in the specified FacesContext. If the conversion attempted in a previous call to decode() for this component failed, the state information saved during execution of decode() should be utilized to reproduce the incorrect input. If the conversion was successful, or if there was no previous call to decode(), the value to be displayed should be acquired by calling currentValue(), and rendering the value as appropriate.

Specified by:
encodeBegin in interface UIComponent
Parameters:
context - FacesContext for the response we are creating
Throws:
java.io.IOException - if an input/output error occurs while rendering

encodeChildren

public void encodeChildren(FacesContext context)
                    throws java.io.IOException
Description copied from interface: UIComponent

Render the child UIComponents of this UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered. This method will only be called if the rendersChildren property is true.

Specified by:
encodeChildren in interface UIComponent
Parameters:
context - FacesContext for the response we are creating
Throws:
java.io.IOException - if an input/output error occurs while rendering

encodeEnd

public void encodeEnd(FacesContext context)
               throws java.io.IOException
Description copied from interface: UIComponent

Render the ending of the current state of this UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered.

Specified by:
encodeEnd in interface UIComponent
Parameters:
context - FacesContext for the response we are creating
Throws:
java.io.IOException - if an input/output error occurs while rendering

reconstitute

public void reconstitute(FacesContext context)
                  throws java.io.IOException
Description copied from interface: UIComponent

Perform any processing required to correct the state of this component as a result of the owning component tree having been reconstructed during Reconstitute Component Tree phase of the request processing lifecycle. The default implementation of this method does nothing.

Specified by:
reconstitute in interface UIComponent
Parameters:
context - FacesContext for the request we are processing
Throws:
java.io.IOException - if an input/output error occurs during processing

updateModel

public void updateModel(FacesContext context)
Description copied from interface: UIComponent

Update the model data associated with this UIComponent, if any. The default implementation in UIComponentBase does no processing; concrete implementations of components that represent controls that can be altered by users (such as UIInput must provide an apppropriate implementation of this method.

Specified by:
updateModel in interface UIComponent
Parameters:
context - FacesContext for the request we are processing

validate

public void validate(FacesContext context)
Description copied from interface: UIComponent

Perform any correctness checks that this component wishes to perform on itself. This method will be called during the Process Validations phase of the request processing lifecycle. If errors are encountered, appropriate Message instances should be added to the FacesContext for the current request, and the valid property of this UIComponent should be set to false.

Specified by:
validate in interface UIComponent
Parameters:
context - FacesContext for the request we are processing

processReconstitutes

public void processReconstitutes(FacesContext context)
                          throws java.io.IOException
Description copied from interface: UIComponent

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

Specified by:
processReconstitutes in interface UIComponent
Parameters:
context - FacesContext for the request we are processing
Throws:
java.io.IOException - if an input/output error occurs during processing

processDecodes

public void processDecodes(FacesContext context)
                    throws java.io.IOException
Description copied from interface: UIComponent

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.


processValidators

public void processValidators(FacesContext context)
Description copied from interface: UIComponent

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.

Specified by:
processValidators in interface UIComponent
Parameters:
context - FacesContext for the request we are processing

processUpdates

public void processUpdates(FacesContext context)
Description copied from interface: UIComponent

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.

Specified by:
processUpdates in interface UIComponent
Parameters:
context - FacesContext for the request we are processing