Top Description Inners Fields Constructors Methods
javax.faces.component

public abstract Class UIComponent

extends Object
implements PartialStateHolder, TransientStateHolder, SystemEventListenerHolder, ComponentSystemEventListener
Class Inheritance
All Implemented Interfaces
javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, java.util.EventListener, javax.faces.event.SystemEventListenerHolder, javax.faces.component.TransientStateHolder, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder
Known Direct Subclasses
javax.faces.component.UIComponentBase
Imports
java.io.IOException, .InputStream, java.util.ArrayDeque, .ArrayList, .Collections, .Enumeration, .HashMap, .HashSet, .Iterator, .List, .Locale, .Map, .MissingResourceException, .PropertyResourceBundle, .ResourceBundle, .Set, java.util.logging.Level, .Logger, javax.el.ELContext, .ELException, .ValueExpression, javax.faces.FacesException, .FacesWrapper, javax.faces.application.Resource, javax.faces.component.visit.VisitCallback, .VisitContext, .VisitHint, .VisitResult, javax.faces.context.FacesContext, javax.faces.el.ValueBinding, javax.faces.event.AbortProcessingException, .PostRestoreStateEvent, .ComponentSystemEvent, .ComponentSystemEventListener, .FacesEvent, .SystemEvent, .SystemEventListener, .FacesListener, .SystemEventListenerHolder, javax.faces.render.Renderer

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.

If the javax.faces.event.ListenerFor annotation is attached to the class definition of a Component, that class must also implement javax.faces.event.ComponentSystemEventListener.

Dynamically modifying the component tree can happen at any time, during and after restoring the view, but not during state saving and needs to function properly with respect to rendering and state saving

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static enum
UIComponent.PropertyKeys

Properties that are tracked by state saving.

pack-priv static enum

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private int
pack-priv List<String>
attributesThatAreSet

List of attributes that have been set on the component (this may be from setValueExpression, the attributes map, or setters from the concrete HTML components.

public static final String
ATTRS_WITH_DECLARED_DEFAULT_VALUES

This constant enables one to quickly discover the names of the declared composite component attributes that have been given default values by the composite component author.

public static final String
BEANINFO_KEY

The value of this constant is used as the key in the component attribute map, the value for which is a java.beans.BeanInfo implementation describing the composite component.

protected Map<String, ValueExpression>
bindings

Deprecated
public static final String
COMPOSITE_COMPONENT_TYPE_KEY

The value of this constant is used as the key in the composite component BeanDescriptor for a ValueExpression that evaluates to the component-type of the composite component root UIComponent for this composite component, if one was declared by the composite component author.

public static final String
COMPOSITE_FACET_NAME

The value of this constant is used as the key in the Map returned as described in FACETS_KEY for the PropertyDescriptor describing the composite component facet.

pack-priv UIComponent
public static final String
CURRENT_COMPONENT

The key to which the UIComponent currently being processed will be associated with within the FacesContext attributes map.

public static final String
CURRENT_COMPOSITE_COMPONENT

The key to which the composite UIComponent currently being processed will be associated with within the FacesContext attributes map.

public static final String
FACETS_KEY

The value of this constant is used as the key in the composite component BeanDescriptor for the Map<PropertyDescriptor> that contains meta-information for the declared facets for this composite component.

public static final String
HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME

The ServletContext init parameter consulted by the UIComponent to tell whether or not the CURRENT_COMPONENT and CURRENT_COMPOSITE_COMPONENT attribute keys should be honored as specified.

pack-priv boolean
private transient Boolean
private boolean
private transient Boolean
private static Logger
private Map<String, String>
pack-priv ComponentStateHelper
public static final String
VIEW_LOCATION_KEY

The value of this constant is used as the key in the component attributes Map for the javax.faces.view.Location in the view at which this component instance resides.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static ArrayDeque<UIComponent>
_getComponentELStack(String keyName, Map<Object, Object> contextAttributes)

protected abstract void
addFacesListener(FacesListener
The FacesListener to be registered
listener
)

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

public abstract void
broadcast(FacesEvent
The FacesEvent to be broadcast
event
)

Broadcast the specified FacesEvent to all registered event listeners who have expressed an interest in events of this type.

public void
clearInitialState()

Implements javax.faces.component.PartialStateHolder.clearInitialState.

An implementation of PartialStateHolder#clearInitialState, this method is called by the runtime to tell the instance to stop tracking state changes.

public abstract void
decode(FacesContext
FacesContext for the request we are processing
context
)

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

public void
encodeAll(FacesContext
the Faces context.
context
)

If this component returns true from isRendered, take the following action.

public abstract void
encodeBegin(FacesContext
FacesContext for the response we are creating
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.

public abstract void
encodeChildren(FacesContext
FacesContext for the response we are creating
context
)

If our rendered property is true, render the child UIComponents of this UIComponent.

public abstract void
encodeEnd(FacesContext
FacesContext for the response we are creating
context
)

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

public abstract UIComponent

Returns:

the found UIComponent, or null if the component was not found.
findComponent
(String
Search expression identifying the UIComponent to be returned
expr
)

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

private Resource
public abstract Map<String, Object>

Returns:

the component attribute 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).

public abstract int

Returns:

the number of child components.
getChildCount
()

Return the number of child UIComponents that are associated with this UIComponent.

public abstract List<UIComponent>

Returns:

the list of children.
getChildren
()

Return a mutable List representing the child UIComponents associated with this component.

public String

Returns:

the client id.
getClientId
()

Enable EL to access the clientId of a component.

public abstract String

Returns:

the client id.
getClientId
(FacesContext
The FacesContext for the current request
context
)

Return a client-side identifier for this component, generating one if necessary.

public static UIComponent

Returns:

if component is null, return null, otherwise search the component's parent hierachy for the nearest parent composite component. If no parent composite component is found, return null
getCompositeComponentParent
(UIComponent
the component from which to start the search from
component
)

Finds the nearest composite component parent of the specified component.

public String

Returns:

the container client id.
getContainerClientId
(FacesContext
the Faces context.
context
)

Allow components that implement NamingContainer to selectively disable prepending their clientId to their descendent's clientIds by breaking the prepending logic into a separately callable method.

public static UIComponent

Returns:

the current component, or null.
getCurrentComponent
(FacesContext
FacesContext for the request we are processing
context
)

Return the UIComponent instance that is currently processing.

public static UIComponent

Returns:

the current composite component, or null.
getCurrentCompositeComponent
(FacesContext
FacesContext for the request we are processing
context
)

Return the closest ancestor component, relative to the component returned from getCurrentComponent, that is a composite component, or null if no such component exists.

protected abstract FacesContext

Returns:

the Faces context.
getFacesContext
()

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

protected abstract FacesListener[]

Returns:

the Faces listeners, or a zero-length array.
getFacesListeners
(Class<T>
Class that must be implemented by a FacesListener for it to be returned
clazz
)

Return an array of registered FacesListeners that are instances of the specified class.

public abstract UIComponent

Returns:

the component, or null.
getFacet
(String
Name of the desired facet
name
)

Convenience method to return the named facet, if it exists, or null otherwise.

public int

Returns:

the number of facets.
getFacetCount
()

Return the number of facet UIComponents that are associated with this UIComponent.

public abstract Map<String, UIComponent>

Returns:

the map of facets.
getFacets
()

Return a mutable Map representing the facet UIComponents associated with this UIComponent, keyed by facet name (which must be a String).

public abstract Iterator<UIComponent>

Returns:

the facets and children iterator.
getFacetsAndChildren
()

Return an Iterator over the facet followed by child UIComponents of this UIComponent.

public abstract String

Returns:

the component family (not null).
getFamily
()

Return the identifier of the component family to which this component belongs.

public abstract String

Returns:

the component identifier.
getId
()

Return the component identifier of this UIComponent.

public List<SystemEventListener>

Returns:

the list of listeners.
getListenersForEventClass
(Class<? extends SystemEvent>
the event class.
eventClass
)

Implements javax.faces.event.SystemEventListenerHolder.getListenersForEventClass.

This implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

public UIComponent

Returns:

the naming container, or null.
getNamingContainer
()

Starting with "this", return the closest component in the ancestry that is a NamingContainer or null if none can be found.

public abstract UIComponent

Returns:

the parent component.
getParent
()

Return the parent UIComponent of this UIComponent, if any.

public Map<String, Object>

Returns:

the pass-through attribute map.
getPassThroughAttributes
()

This is a convenience method that simply calls getPassThroughAttributes(boolean), passing true as the argument.

public Map<String, Object>

Returns:

A Map instance, or null.
getPassThroughAttributes
(boolean
if true, a new Map instance will be created if it does not exist already. If false, and there is no existing Map instance, one will not be created and null will be returned.
create
)

This method has the same specification as getPassThroughAttributes() except that it is allowed to return null if and only if the argument create is false and no pass through attribute data structure exists for this instance.

protected abstract Renderer

Returns:

the renderer, or null.
getRenderer
(FacesContext
FacesContext for the current request
context
)

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

public abstract String

Returns:

the renderer type.
getRendererType
()

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

public abstract boolean

Returns:

true if the component renders its children, false otherwise.
getRendersChildren
()

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

public Map<String, String>

Returns:

the resource bundle map.
getResourceBundleMap
()

Return a Map<String,String> of the ResourceBundle for this component.

protected StateHelper

Returns:

the state helper.
getStateHelper
()

Return the StateHelper instance used to help this component implement PartialStateHolder.

protected StateHelper

Returns:

the state helper.
getStateHelper
(boolean
if true, a new StateHelper instance will be created if it does not exist already. If false, and there is no existing StateHelper instance, one will not be created and null will be returned.
create
)

Like getStateHelper(), but only create a state helper instance if the argument creat is true.

public TransientStateHelper

Returns:

the transient state helper.
getTransientStateHelper
()

Return the TransientStateHelper instance for this UIComponent instance.

public TransientStateHelper

Returns:

the transient state helper.
getTransientStateHelper
(boolean
if true create, if necessary, any internal data structures. If false, do not create any instances. In this case, it is possible for this method to return null.
create
)

Return the TransientStateHelper instance for this UIComponent instance.

public abstract ValueBinding

Returns:

the value binding.
getValueBinding
(String
Name of the attribute or property for which to retrieve a ValueBinding
name
)

Deprecated This has been replaced by getValueExpression.

Call through to getValueExpression and examine the result.

public ValueExpression

Returns:

the value expression, or null.
getValueExpression
(String
Name of the attribute or property for which to retrieve a ValueExpression
name
)

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

public boolean
initialStateMarked()

Implements javax.faces.component.PartialStateHolder.initialStateMarked.

An implementation of PartialStateHolder#initialStateMarked, this method is called by the runtime to test if the PartialStateHolder#markInitialState method was called.

public boolean

Returns:

true if the a component with the given clientId is found, the callback method was successfully invoked passing that component as an argument, and no Exception was thrown. Returns false if no component with the given clientId is found.
invokeOnComponent
(FacesContext
the FacesContext for the current request
context
,
String
the client identifier of the component to be passed to the argument callback.
clientId
,
ContextCallback
an implementation of the Callback interface.
callback
)

Starting at this component in the View hierarchy, search for a component with a clientId equal to the argument clientId and, if found, call the ContextCallback#invokeContextCallback method on the argument callback, passing the current FacesContext and the found component as arguments.

public static boolean

Returns:

true if this is a composite component, false otherwise.
isCompositeComponent
(UIComponent
the UIComponent to test
component
)

Return true if component is a composite component, otherwise false.

public boolean

Returns:

true if within a view hierarchy, false otherwise.
isInView
()

Return true if this component is within the view hierarchy otherwise false

public abstract boolean

Returns:

true if the component should be rendered, false otherwise.
isRendered
()

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

private boolean
protected boolean

Returns:

true if visitable, false otherwise.
isVisitable
(VisitContext
the Visit context.
context
)

Return true if this component should be visited, false otherwise.

public void
markInitialState()

Implements javax.faces.component.PartialStateHolder.markInitialState.

An implementation of PartialStateHolder#markInitialState, this method is called by the runtime to indicate that the instance should start tracking changes to its state.

public void
popComponentFromEL(FacesContext
the FacesContext for the current request
context
)

Pop the current UIComponent from the FacesContext attributes map so that the previous UIComponent, if any, becomes the current component.

public abstract void
processDecodes(FacesContext
FacesContext for the request we are processing
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.

public void
processEvent(ComponentSystemEvent
the ComponentSystemEvent instance that is being processed.
event
)

Implements javax.faces.event.ComponentSystemEventListener.processEvent.

The default implementation performs the following action.

public abstract void
processRestoreState(FacesContext
FacesContext for the request we are processing
context
,
Object
the state.
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.

public abstract Object

Returns:

the saved state.
processSaveState
(FacesContext
FacesContext for the request we are processing
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.

public abstract void
processUpdates(FacesContext
FacesContext for the request we are processing
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.

public abstract void
processValidators(FacesContext
FacesContext for the request we are processing
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.

public void
pushComponentToEL(FacesContext
the FacesContext for the current request
context
,
UIComponent
the component to push to the EL. If component is null the UIComponent instance that this call was invoked upon will be pushed to the EL.
component
)

Push the current UIComponent this to the FacesContext attribute map using the key CURRENT_COMPONENT saving the previous UIComponent associated with CURRENT_COMPONENT for a subsequent call to popComponentFromEL.

public abstract void
queueEvent(FacesEvent
FacesEvent to be queued
event
)

Queue an event for broadcast at the end of the current request processing lifecycle phase.

protected abstract void
removeFacesListener(FacesListener
The FacesListener to be deregistered
listener
)

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

public void
restoreTransientState(FacesContext
the Faces context
context
,
Object
the object containing transient values
state
)

Implements javax.faces.component.TransientStateHolder.restoreTransientState.

For components that need to support the concept of transient state, this method will restore any state saved on a prior call to saveTransientState.

public Object
saveTransientState(FacesContext
the Faces context.
context
)

Implements javax.faces.component.TransientStateHolder.saveTransientState.

For components that need to support the concept of transient state, this method will save any state that is known to be transient in nature.

public abstract void
setId(String
The new component identifier, or null to indicate that this UIComponent does not have a component identifier
id
)

Set the component identifier of this UIComponent (if any).

public void
setInView(boolean
flag indicating whether or not this component is within the view hierachy
isInView
)

Updates the status as to whether or not this component is currently within the view hierarchy.

public abstract void
setParent(UIComponent
The new parent, or null for the root node of a component tree
parent
)

Set the parent UIComponent of this UIComponent.

public abstract void
setRendered(boolean
If true render this component; otherwise, do not render this component
rendered
)

Set the rendered property of this UIComponent.

public abstract void
setRendererType(String
Logical identifier of the type of Renderer to use, or null for components that render themselves
rendererType
)

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

public abstract void
setValueBinding(String
Name of the attribute or property for which to set a ValueBinding
name
,
ValueBinding
The ValueBinding to set, or null to remove any currently set ValueBinding
binding
)

Deprecated This has been replaced by setValueExpression.

Wrap the argument binding in an implementation of ValueExpression and call through to setValueExpression.

public void
setValueExpression(String
Name of the attribute or property for which to set a ValueExpression
name
,
ValueExpression
The ValueExpression to set, or null to remove any currently set ValueExpression
binding
)

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

public void
subscribeToEvent(Class<? extends SystemEvent>
the event class.
eventClass
,
ComponentSystemEventListener
the listener.
componentListener
)

This implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

public void
unsubscribeFromEvent(Class<? extends SystemEvent>
the event class.
eventClass
,
ComponentSystemEventListener
the component listener.
componentListener
)

This implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

public boolean

Returns:

component implementations may return true to indicate that the tree visit is complete (eg. all components that need to be visited have been visited). This results in the tree visit being short-circuited such that no more components are visited.
visitTree(VisitContext
the VisitContext for this visit
context
,
VisitCallback
the VisitCallback instance whose visit method will be called for each node visited.
callback
)

Perform a tree visit starting at this node in the tree.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait