@JSFComponent(type="javax.faces.ComponentBase",
family="javax.faces.ComponentBase",
desc="base component when all components must inherit",
tagClass="javax.faces.webapp.UIComponentELTag",
configExcluded=true)
@JSFJspProperty(name="binding",
returnType="javax.faces.component.UIComponent",
longDesc="Identifies a backing bean property (of type UIComponent or appropriate subclass) to bind to this component instance. This value must be an EL expression.",
desc="backing bean property to bind to this component instance")
public abstract class UIComponentBase
extends UIComponent
Disclaimer: The official definition for the behaviour of this class is the JSF 1.1 specification but for legal reasons the specification cannot be replicated here. Any javadoc here therefore describes the current implementation rather than the spec, though this class has been verified as correctly implementing the spec. see Javadoc of JSF Specification for more.
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY| Constructor and Description |
|---|
UIComponentBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
addClientBehavior(String eventName,
ClientBehavior behavior) |
protected void |
addFacesListener(FacesListener 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.
|
void |
clearInitialState() |
void |
decode(FacesContext context)
Check the submitted form parameters for data associated with this component.
|
void |
encodeAll(FacesContext context) |
void |
encodeBegin(FacesContext context) |
void |
encodeChildren(FacesContext context) |
void |
encodeEnd(FacesContext context) |
UIComponent |
findComponent(String expr)
Standard method for finding other components by id, inherited by most UIComponent objects.
|
Map<String,Object> |
getAttributes()
Get a map through which all the UIComponent's properties, value-bindings and non-property attributes can be read
and written.
|
int |
getChildCount()
Return the number of direct child components this component has.
|
List<UIComponent> |
getChildren()
Return a list of the UIComponent objects which are direct children of this component.
|
Map<String,List<ClientBehavior>> |
getClientBehaviors() |
String |
getClientId(FacesContext context)
Get a string which can be output to the response which uniquely identifies this UIComponent within the current
view.
|
String |
getDefaultEventName() |
Collection<String> |
getEventNames() |
protected FacesContext |
getFacesContext() |
protected FacesListener[] |
getFacesListeners(Class clazz) |
UIComponent |
getFacet(String name) |
int |
getFacetCount() |
Map<String,UIComponent> |
getFacets() |
Iterator<UIComponent> |
getFacetsAndChildren() |
String |
getId()
Get a string which uniquely identifies this UIComponent within the scope of the nearest ancestor NamingContainer
component.
|
UIComponent |
getParent()
Returns the parent of the component.
|
Map<String,Object> |
getPassThroughAttributes(boolean create) |
protected Renderer |
getRenderer(FacesContext context) |
String |
getRendererType() |
boolean |
getRendersChildren()
Indicates whether this component or its renderer manages the invocation of the rendering methods of its child
components.
|
ValueBinding |
getValueBinding(String name)
Deprecated.
Replaced by getValueExpression
|
boolean |
invokeOnComponent(FacesContext context,
String clientId,
ContextCallback callback)
invokeOnComponent must be implemented in UIComponentBase too... |
boolean |
isRendered()
A boolean value that indicates whether this component should be rendered.
|
boolean |
isTransient() |
void |
markInitialState() |
void |
processDecodes(FacesContext context) |
void |
processRestoreState(FacesContext context,
Object state) |
Object |
processSaveState(FacesContext context) |
void |
processUpdates(FacesContext context)
This isn't an input component, so just pass on the processUpdates call to child components and facets that might
be input components.
|
void |
processValidators(FacesContext context) |
void |
queueEvent(FacesEvent event) |
protected void |
removeFacesListener(FacesListener listener) |
static Object |
restoreAttachedState(FacesContext context,
Object stateObj) |
void |
restoreState(FacesContext context,
Object state)
Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into
the provided state object.
|
static Object |
saveAttachedState(FacesContext context,
Object attachedObject)
Serializes objects which are "attached" to this component but which are not UIComponent children of it.
|
Object |
saveState(FacesContext context)
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 |
setId(String id)
Set an identifier for this component which is unique within the scope of the nearest ancestor NamingContainer
component.
|
void |
setParent(UIComponent parent)
Set the parent
UIComponent of this
UIComponent. |
void |
setRendered(boolean rendered) |
void |
setRendererType(String rendererType) |
void |
setTransient(boolean transientFlag) |
void |
setValueBinding(String name,
ValueBinding binding)
Deprecated.
Replaced by setValueExpression
|
boolean |
visitTree(VisitContext context,
VisitCallback callback)
The visit tree method, visit tree walks over a subtree and processes
the callback object to perform some operation on the subtree
|
getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getFamily, getListenersForEventClass, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEventpublic void setValueBinding(String name, ValueBinding binding)
setValueBinding in class UIComponentpublic void setId(String id)
The id must start with an underscore if it is generated by the JSF framework, and must not start with an underscore if it has been specified by the user (eg in a JSP tag).
The first character of the id must be an underscore or letter. Following characters may be letters, digits, underscores or dashes.
Null is allowed as a parameter, and will reset the id to null.
The clientId of this component is reset by this method; see getClientId for more info.
setId in class UIComponentIllegalArgumentException - if the id is not valid.public void setParent(UIComponent parent)
Set the parent UIComponent of this
UIComponent.
setParent in class UIComponentparent - The new parent, or null for the root node
of a component treepublic void addClientBehavior(String eventName, ClientBehavior behavior)
eventName - behavior - public void broadcast(FacesEvent event) throws AbortProcessingException
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.
broadcast in class UIComponentevent - must not be null.AbortProcessingExceptionpublic void clearInitialState()
UIComponentclearInitialState in interface PartialStateHolderclearInitialState in class UIComponentpublic void decode(FacesContext context)
decode in class UIComponentpublic void encodeAll(FacesContext context) throws IOException
encodeAll in class UIComponentIOExceptionpublic void encodeBegin(FacesContext context) throws IOException
encodeBegin in class UIComponentIOExceptionpublic void encodeChildren(FacesContext context) throws IOException
encodeChildren in class UIComponentIOExceptionpublic void encodeEnd(FacesContext context) throws IOException
encodeEnd in class UIComponentIOExceptionpublic UIComponent findComponent(String expr)
The lookup is performed in a manner similar to finding a file in a filesystem; there is a "base" at which to start, and the id can be for something in the "local directory", or can include a relative path. Here, NamingContainer components fill the role of directories, and ":" is the "path separator". Note, however, that although components have a strict parent/child hierarchy, component ids are only prefixed ("namespaced") with the id of their parent when the parent is a NamingContainer.
The base node at which the search starts is determined as follows:
findComponent in class UIComponentexpr - is of form "id1:id2:id3".public Map<String,Object> getAttributes()
When writing to the returned map:
When reading from the returned map:
Assigning values to the map which are not explicit properties on the underlying component can be used to "tunnel" attributes from the JSP tag (or view-specific equivalent) to the associated renderer without modifying the component itself.
Any value-bindings and non-property attributes stored in this map are automatically serialized along with the component when the view is serialized.
getAttributes in class UIComponentpublic Map<String,Object> getPassThroughAttributes(boolean create)
getPassThroughAttributes in class UIComponentMap instance, or null.public int getChildCount()
Identical to getChildren().size() except that when this component has no children this method will not force an empty list to be created.
getChildCount in class UIComponentpublic List<UIComponent> getChildren()
The list object returned has some non-standard behaviour:
getChildren in class UIComponentpublic Map<String,List<ClientBehavior>> getClientBehaviors()
public String getClientId(FacesContext context)
The component should have an id attribute already assigned to it; however if the id property is currently null then a unique id is generated and set for this component. This only happens when components are programmatically created without ids, as components created by a ViewHandler should be assigned ids when they are created.
If this component is a descendant of a NamingContainer then the client id is of form "{namingContainerId}:{componentId}". Note that the naming container's id may itself be of compound form if it has an ancestor naming container. Note also that this only applies to naming containers; other UIComponent types in the component's ancestry do not affect the clientId.
Finally the renderer associated with this component is asked to convert the id into a suitable form. This allows escaping of any characters in the clientId which are significant for the markup language generated by that renderer.
getClientId in class UIComponentpublic String getDefaultEventName()
public Collection<String> getEventNames()
public UIComponent getFacet(String name)
getFacet in class UIComponentpublic int getFacetCount()
getFacetCount in class UIComponentpublic Map<String,UIComponent> getFacets()
getFacets in class UIComponentpublic Iterator<UIComponent> getFacetsAndChildren()
getFacetsAndChildren in class UIComponent@JSFProperty(rtexprvalue=true) public String getId()
getId in class UIComponentpublic UIComponent getParent()
UIComponentgetParent in class UIComponentpublic String getRendererType()
getRendererType in class UIComponentpublic boolean getRendersChildren()
getRendersChildren in class UIComponentpublic ValueBinding getValueBinding(String name)
Value-bindings are stored in a map associated with the component, though there is commonly a property (setter/getter methods) of the same name defined on the component itself which evaluates the value-binding when called.
getValueBinding in class UIComponentpublic boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback) throws FacesException
invokeOnComponent must be implemented in UIComponentBase too...invokeOnComponent in class UIComponentcontext - FacesContext for the current requestclientId - the id of the desired UIComponent clazzcallback - Implementation of the ContextCallback to be calledFacesExceptionpublic boolean visitTree(VisitContext context, VisitCallback callback)
UIComponentthere are some details in the implementation which according to the spec have to be in place: a) before calling the callback and traversing into the subtree pushComponentToEL has to be called b) after the processing popComponentFromEL has to be performed to remove the component from the el
The tree traversal optimizations are located in the visit context and can be replaced via the VisitContextFactory in the faces-config factory section
visitTree in class UIComponentcontext - the visit context which handles the processing detailscallback - the callback to be performed@JSFProperty public boolean isRendered()
isRendered in class UIComponent@JSFProperty(literalOnly=true,
istransient=true,
tagExcluded=true)
public boolean isTransient()
public void markInitialState()
markInitialState in interface PartialStateHoldermarkInitialState in class UIComponentprotected void addFacesListener(FacesListener listener)
addFacesListener in class UIComponentprotected FacesContext getFacesContext()
getFacesContext in class UIComponentprotected FacesListener[] getFacesListeners(Class clazz)
getFacesListeners in class UIComponentprotected Renderer getRenderer(FacesContext context)
getRenderer in class UIComponentprotected void removeFacesListener(FacesListener listener)
removeFacesListener in class UIComponentpublic void queueEvent(FacesEvent event)
queueEvent in class UIComponentpublic void processDecodes(FacesContext context)
processDecodes in class UIComponentpublic void processValidators(FacesContext context)
processValidators in class UIComponentpublic void processUpdates(FacesContext context)
Components that were never rendered can't possibly be receiving update data (no corresponding fields were ever put into the response) so if this component is not rendered then this method does not invoke processUpdates on its children.
processUpdates in class UIComponentpublic Object processSaveState(FacesContext context)
processSaveState in class UIComponentpublic void processRestoreState(FacesContext context, Object state)
processRestoreState in class UIComponentpublic void setTransient(boolean transientFlag)
public static Object saveAttachedState(FacesContext context, Object attachedObject)
If the attachedObject is a List then every object in the list is saved via a call to this method, and the returned wrapper object contains a List object.
If the object implements StateHolder then the object's saveState is called immediately, and a wrapper is returned which contains both this saved state and the original class name. However in the case where the StateHolder.isTransient method returns true, null is returned instead.
If the object implements java.io.Serializable then the object is simply returned immediately; standard java serialization will later be used to store this object.
In all other cases, a wrapper is returned which simply stores the type of the provided object. When deserialized, a default instance of that type will be recreated.
public static Object restoreAttachedState(FacesContext context, Object stateObj) throws IllegalStateException
IllegalStateExceptionpublic Object saveState(FacesContext context)
public void restoreState(FacesContext context, Object state)
state - is an object previously returned by the saveState method of this class.public void setRendered(boolean rendered)
setRendered in class UIComponentpublic void setRendererType(String rendererType)
setRendererType in class UIComponentCopyright © 2025 The Apache Software Foundation. All rights reserved.