- All Implemented Interfaces:
- PartialStateHolder,- StateHolder,- TransientStateHolder,- ComponentSystemEventListener,- FacesListener,- SystemEventListenerHolder,- EventListener
- Direct Known Subclasses:
- BehaviorHolderWrapper,- UIComponentBase
 UIComponent is the base class for all user interface components in Jakarta Server
 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 ListenerFor annotation is attached to the class definition of a
 Component, that class must also implement 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
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThis 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.static final StringThe value of this constant is used as the key in the component attribute map, the value for which is ajava.beans.BeanInfoimplementation describing the composite component.static final StringThe value of this constant is used as the key in the composite component BeanDescriptor for aValueExpressionthat evaluates to thecomponent-typeof the composite component rootUIComponentfor this composite component, if one was declared by the composite component author.static final StringThe value of this constant is used as the key in theMapreturned as described inFACETS_KEYfor thePropertyDescriptordescribing the composite component facet.static final StringThe value of this constant is used as the key in the composite component BeanDescriptor for theMap<PropertyDescriptor>that contains meta-information for the declared facets for this composite component.static final StringThe value of this constant is used as the key in the component attributesMapfor theLocationin the view at which this component instance resides.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voidaddFacesListener(FacesListener listener) Add the specifiedFacesListenerto the set of listeners registered to receive event notifications from thisUIComponent.abstract voidbroadcast(FacesEvent event) Broadcast the specifiedFacesEventto all registered event listeners who have expressed an interest in events of this type.voidAn implementation ofPartialStateHolder.clearInitialState(), this method is called by the runtime to tell the instance to stop tracking state changes.abstract voiddecode(FacesContext context) Decode any new state of thisUIComponentfrom the request contained in the specifiedFacesContext, and store this state as needed.voidencodeAll(FacesContext context) If this component returnstruefromisRendered(), take the following action.abstract voidencodeBegin(FacesContext context) If ourrenderedproperty istrue, render the beginning of the current state of thisUIComponentto the response contained in the specifiedFacesContext.abstract voidencodeChildren(FacesContext context) abstract voidencodeEnd(FacesContext context) abstract UIComponentfindComponent(String expr) Search for and return theUIComponentwith anidthat matches the specified search expression (if any), according to the algorithm described below.Return a mutableMaprepresenting the attributes (and properties, see below) associated wth thisUIComponent, keyed by attribute name (which must be a String).abstract intReturn the number of childUIComponents that are associated with thisUIComponent.abstract List<UIComponent> Enable Jakarta Expression Language to access theclientIdof a component.abstract StringgetClientId(FacesContext context) Return a client-side identifier for this component, generating one if necessary.static UIComponentgetCompositeComponentParent(UIComponent component) Finds the nearest composite component parent of the specified component.getContainerClientId(FacesContext context) Allow components that implementNamingContainerto selectively disable prepending their clientId to their descendent's clientIds by breaking the prepending logic into a separately callable method.static UIComponentgetCurrentComponent(FacesContext context) Return theUIComponentinstance that is currently processing.static UIComponentgetCurrentCompositeComponent(FacesContext context) Return the closest ancestor component, relative to the component returned fromgetCurrentComponent(jakarta.faces.context.FacesContext), that is a composite component, ornullif no such component exists.protected abstract FacesContextConvenience method to return theFacesContextinstance for the current request.protected abstract FacesListener[]getFacesListeners(Class clazz) Return an array of registeredFacesListeners that are instances of the specified class.abstract UIComponentConvenience method to return the named facet, if it exists, ornullotherwise.intReturn the number of facetUIComponents that are associated with thisUIComponent.abstract Map<String, UIComponent> Return a mutableMaprepresenting the facetUIComponents associated with thisUIComponent, keyed by facet name (which must be a String).abstract Iterator<UIComponent> abstract StringReturn the identifier of the component family to which this component belongs.abstract StringgetId()Return the component identifier of thisUIComponent.getListenersForEventClass(Class<? extends SystemEvent> eventClass) This implementation throwsUnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.Starting with "this", return the closest component in the ancestry that is aNamingContainerornullif none can be found.abstract UIComponentReturn the parentUIComponentof thisUIComponent, if any.This is a convenience method that simply callsgetPassThroughAttributes(boolean), passingtrueas the argument.getPassThroughAttributes(boolean create) This method has the same specification asgetPassThroughAttributes()except that it is allowed to returnnullif and only if the argumentcreateisfalseand no pass through attribute data structure exists for this instance.protected abstract RenderergetRenderer(FacesContext context) Convenience method to return theRendererinstance associated with this component, if any; otherwise, returnnull.abstract StringReturn theRenderertype for thisUIComponent(if any).abstract booleanReturn a flag indicating whether this component is responsible for rendering its child components.Return aMap<String,String>of theResourceBundlefor this component.protected StateHelperReturn theStateHelperinstance used to help this component implementPartialStateHolder.protected StateHelpergetStateHelper(boolean create) Return theTransientStateHelperinstance for thisUIComponentinstance.getTransientStateHelper(boolean create) Return theTransientStateHelperinstance for thisUIComponentinstance.getValueExpression(String name) Return theValueExpressionused to calculate the value for the specified attribute or property name, if any.booleanAn implementation ofPartialStateHolder.initialStateMarked(), this method is called by the runtime to test if thePartialStateHolder.markInitialState()method was called.booleaninvokeOnComponent(FacesContext context, String clientId, ContextCallback callback) Starting at this component in the View hierarchy, search for a component with aclientIdequal to the argumentclientIdand, if found, call theContextCallback.invokeContextCallback(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent)method on the argumentcallback, passing the currentFacesContextand the found component as arguments.static booleanisCompositeComponent(UIComponent component) Returntrueifcomponentis a composite component, otherwisefalse.booleanisInView()Returntrueif this component is within the view hierarchy otherwisefalseabstract booleanReturntrueif this component (and its children) should be rendered during the Render Response phase of the request processing lifecycle.protected booleanisVisitable(VisitContext context) Returntrueif this component should be visited,falseotherwise.voidAn implementation ofPartialStateHolder.markInitialState(), this method is called by the runtime to indicate that the instance should start tracking changes to its state.voidpopComponentFromEL(FacesContext context) Pop the currentUIComponentfrom theFacesContextattributes map so that the previousUIComponent, if any, becomes the current component.abstract voidprocessDecodes(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.voidprocessEvent(ComponentSystemEvent event) The default implementation performs the following action.abstract voidprocessRestoreState(FacesContext context, 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 ObjectprocessSaveState(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 voidprocessUpdates(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 voidprocessValidators(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.voidpushComponentToEL(FacesContext context, UIComponent component) Push the currentUIComponentthisto theFacesContextattribute map saving the previousUIComponentfor a subsequent call topopComponentFromEL(jakarta.faces.context.FacesContext).abstract voidqueueEvent(FacesEvent event) Queue an event for broadcast at the end of the current request processing lifecycle phase.protected abstract voidremoveFacesListener(FacesListener listener) Remove the specifiedFacesListenerfrom the set of listeners registered to receive event notifications from thisUIComponent.voidrestoreTransientState(FacesContext context, Object state) For components that need to support the concept of transient state, this method will restore any state saved on a prior call tosaveTransientState(jakarta.faces.context.FacesContext).saveTransientState(FacesContext context) 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.abstract voidSet the component identifier of thisUIComponent(if any).voidsetInView(boolean isInView) Updates the status as to whether or not this component is currently within the view hierarchy.abstract voidsetParent(UIComponent parent) Set the parentUIComponentof thisUIComponent.abstract voidsetRendered(boolean rendered) Set therenderedproperty of thisUIComponent.abstract voidsetRendererType(String rendererType) voidsetValueExpression(String name, ValueExpression binding) Set theValueExpressionused to calculate the value for the specified attribute or property name, if any.voidsubscribeToEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener) This implementation throwsUnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.voidunsubscribeFromEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener) This implementation throwsUnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.booleanvisitTree(VisitContext visitContext, VisitCallback callback) Perform a tree visit starting at this node in the tree.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.faces.component.StateHolderisTransient, restoreState, saveState, setTransient
- 
Field Details- 
BEANINFO_KEYThe value of this constant is used as the key in the component attribute map, the value for which is a java.beans.BeanInfoimplementation describing the composite component. ThisBeanInfois known as the composite component BeanInfo.- Since:
- 2.0
- See Also:
 
- 
FACETS_KEYThe 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. This map must contain an entry under the keyCOMPOSITE_FACET_NAME, even if no facets were explicitly declared. SeeCOMPOSITE_FACET_NAME.- Since:
- 2.0
- See Also:
 
- 
VIEW_LOCATION_KEY
- 
COMPOSITE_COMPONENT_TYPE_KEYThe value of this constant is used as the key in the composite component BeanDescriptor for a ValueExpressionthat evaluates to thecomponent-typeof the composite component rootUIComponentfor this composite component, if one was declared by the composite component author.- Since:
- 2.0
- See Also:
 
- 
COMPOSITE_FACET_NAMEThe value of this constant is used as the key in the Mapreturned as described inFACETS_KEYfor thePropertyDescriptordescribing the composite component facet. The value of this constant is also used as the key in theMapreturned fromgetFacets(). In this case, it refers to the actual facet that is theUIPanelthat is the parent of the all of the components in the<composite:implementation>section of the composite component VDL file.- Since:
- 2.0
- See Also:
 
- 
ATTRS_WITH_DECLARED_DEFAULT_VALUESThis 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. The information is exposed as a Collection<String>returned from thegetValue()method on the composite component BeanDescriptor, when this constant is passed as the argument.- Since:
- 2.1
- See Also:
 
 
- 
- 
Constructor Details- 
UIComponentpublic UIComponent()
 
- 
- 
Method Details- 
getAttributesReturn a mutable Maprepresenting the attributes (and properties, see below) associated wth thisUIComponent, keyed by attribute name (which must be a String). The returned implementation must support all of the standard and optionalMapmethods, plus support the following additional requirements:- The Mapimplementation must implement thejava.io.Serializableinterface.
- Any attempt to add a nullkey or value must throw aNullPointerException.
- Any attempt to add a key that is not a String must throw a ClassCastException.
- If the attribute name specified as a key matches a property of this UIComponent's implementation class, the following methods will have special behavior:- containsKey- Return- false.
- get()- If the property is readable, call the getter method and return the returned value (wrapping primitive values in their corresponding wrapper classes); otherwise throw- IllegalArgumentException.
- put()- If the property is writeable, call the setter method to set the corresponding value (unwrapping primitive values in their corresponding wrapper classes). If the property is not writeable, or an attempt is made to set a property of primitive type to- null, throw- IllegalArgumentException.
- remove- Throw- IllegalArgumentException.
 
 - Returns:
- the component attribute map.
 
- The 
- 
getPassThroughAttributesThis is a convenience method that simply calls getPassThroughAttributes(boolean), passingtrueas the argument. This method must never returnnull.- Returns:
- the pass-through attribute map.
- Since:
- 2.2
 
- 
getPassThroughAttributesThis method has the same specification as getPassThroughAttributes()except that it is allowed to returnnullif and only if the argumentcreateisfalseand no pass through attribute data structure exists for this instance. The returnedMapimplementation must support all of the standard and optionalMapmethods, plus support the following additional requirements. The map must be stored in usinggetStateHelper().The Mapimplementation must implementjava.io.Serializable.Any attempt to add a nullkey or value must throw aNullPointerException.Any attempt to add a key that is not a Stringmust throw anIllegalArgumentException.For backward compatibility with components that extend directly from this class, a default implementation is provided that returns the empty map. - Parameters:
- create- if- true, a new- Mapinstance will be created if it does not exist already. If- false, and there is no existing- Mapinstance, one will not be created and- nullwill be returned.
- Returns:
- A Mapinstance, ornull.
- Since:
- 2.2
 
- 
getValueExpressionReturn the ValueExpressionused to calculate the value for the specified attribute or property name, if any.This method must be overridden and implemented for components that comply with Jakarta Faces 1.2 and later. - Parameters:
- name- Name of the attribute or property for which to retrieve a- ValueExpression
- Returns:
- the value expression, or null.
- Throws:
- NullPointerException- if- nameis- null
- Since:
- 1.2
 
- 
setValueExpressionSet the ValueExpressionused to calculate the value for the specified attribute or property name, if any.The implementation must call Expression.isLiteralText()on the argumentexpression. IfisLiteralText()returnstrue, invokeValueExpression.getValue(jakarta.el.ELContext)on the argument expression and pass the result as thevalueparameter in a call tothis.wheregetAttributes().put(name, value)nameis the argumentname. If an exception is thrown as a result of callingValueExpression.getValue(jakarta.el.ELContext), wrap it in aFacesExceptionand re-throw it. IfisLiteralText()returnsfalse, simply store the un-evaluatedexpressionargument in the collection ofValueExpressions under the key given by the argumentname.This method must be overridden and implemented for components that comply with Jakarta Faces 1.2 and later. - Parameters:
- name- Name of the attribute or property for which to set a- ValueExpression
- binding- The- ValueExpressionto set, or- nullto remove any currently set- ValueExpression
- Throws:
- IllegalArgumentException- if- nameis one of- idor- parent
- NullPointerException- if- nameis- null
- Since:
- 1.2
 
- 
markInitialStatepublic void 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.- Specified by:
- markInitialStatein interface- PartialStateHolder
- Since:
- 2.0
 
- 
initialStateMarkedpublic boolean initialStateMarked()An implementation of PartialStateHolder.initialStateMarked(), this method is called by the runtime to test if thePartialStateHolder.markInitialState()method was called.- Specified by:
- initialStateMarkedin interface- PartialStateHolder
- Returns:
- trueif the initial state is marked,- falseotherwise.
- Since:
- 2.0
 
- 
clearInitialStatepublic void clearInitialState()An implementation of PartialStateHolder.clearInitialState(), this method is called by the runtime to tell the instance to stop tracking state changes.- Specified by:
- clearInitialStatein interface- PartialStateHolder
- Since:
- 2.0
 
- 
getStateHelperReturn the StateHelperinstance used to help this component implementPartialStateHolder.- Returns:
- the state helper.
- Since:
- 2.0
 
- 
getStateHelperLike getStateHelper(), but only create a state helper instance if the argumentcreatistrue.- Parameters:
- create- if- true, a new- StateHelperinstance will be created if it does not exist already. If- false, and there is no existing- StateHelperinstance, one will not be created and- nullwill be returned.
- Returns:
- the state helper.
- Since:
- 2.0
 
- 
getTransientStateHelperReturn the TransientStateHelperinstance for thisUIComponentinstance. The default implementation simply calls through togetTransientStateHelper(boolean)passingtrueas the argument.- Returns:
- the transient state helper.
- Since:
- 2.1
 
- 
getTransientStateHelperReturn the TransientStateHelperinstance for thisUIComponentinstance.- Parameters:
- create- if- truecreate, 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.
- Returns:
- the transient state helper.
- Since:
- 2.1
 
- 
restoreTransientStateFor components that need to support the concept of transient state, this method will restore any state saved on a prior call to saveTransientState(jakarta.faces.context.FacesContext).- Specified by:
- restoreTransientStatein interface- TransientStateHolder
- Parameters:
- context- the Faces context
- state- the object containing transient values
- Since:
- 2.1
 
- 
saveTransientStateFor components that need to support the concept of transient state, this method will save any state that is known to be transient in nature. - Specified by:
- saveTransientStatein interface- TransientStateHolder
- Parameters:
- context- the Faces context.
- Returns:
- object containing transient values
- Since:
- 2.1
 
- 
isInViewpublic boolean isInView()Return trueif this component is within the view hierarchy otherwisefalse- Returns:
- trueif within a view hierarchy,- falseotherwise.
- Since:
- 2.0
 
- 
setInViewpublic void setInView(boolean isInView) Updates the status as to whether or not this component is currently within the view hierarchy. 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 childListor facetMap.- Parameters:
- isInView- flag indicating whether or not this component is within the view hierachy
- Since:
- 2.0
 
- 
getClientIdEnable Jakarta Expression Language to access the clientIdof a component. This is particularly useful in combination with thecomponentandccimplicit objects. A default implementation is provided that simply callsFacesContext.getCurrentInstance()and then calls through togetClientId(FacesContext).- Returns:
- the client id.
- Since:
- 2.0
 
- 
getClientIdReturn 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 idproperty of the component is changed, or the component is placed in aNamingContainerwhose client ID changes (for example,UIData). However, even in these cases, consecutive calls to this method must always return the same value. The implementation must follow these steps in determining the clientId:Find the closest ancestor to this component in the view hierarchy that implements NamingContainer. CallgetContainerClientId()on it and save the result as theparentIdlocal variable. CallgetId()on this component and save the result as themyIdlocal variable. IfmyIdisnull, callcontext.getViewRoot().createUniqueId()and assign the result to myId. IfparentIdis non-null, letmyIdequalparentId +. CallUINamingContainer.getSeparatorChar(jakarta.faces.context.FacesContext)+ myIdRenderer.convertClientId(jakarta.faces.context.FacesContext, java.lang.String), passingmyId, and return the result.- Parameters:
- context- The- FacesContextfor the current request
- Returns:
- the client id.
- Throws:
- NullPointerException- if- contextis- null
 
- 
getContainerClientIdAllow components that implement NamingContainerto selectively disable prepending their clientId to their descendent's clientIds by breaking the prepending logic into a separately callable method. SeegetClientId()for usage.By default, this method will call through to getClientId()and return the result.- Parameters:
- context- the Faces context.
- Returns:
- the container client id.
- Throws:
- NullPointerException- if- contextis- null
- Since:
- 1.2
 
- 
getFamilyReturn the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the rendererTypeproperty, may be used to select the appropriateRendererfor this component instance. Note this method should NOT returnnull- Returns:
- the component family (not null).
 
- 
getIdReturn the component identifier of this UIComponent.- Returns:
- the component identifier.
 
- 
setIdSet the component identifier of this UIComponent(if any). Component identifiers must obey the following syntax restrictions:- Must not be a zero-length String.
- First character must be a letter or an underscore ('_').
- Subsequent characters must be a letter, a digit, an underscore ('_'), or a dash ('-').
 Component identifiers must also obey the following semantic restrictions (note that this restriction is NOT enforced by the setId()implementation):- The specified identifier must be unique among all the components (including facets) that are descendents of the
 nearest ancestor UIComponentthat is aNamingContainer, or within the scope of the entire component tree if there is no such ancestor that is aNamingContainer.
 - Parameters:
- id- The new component identifier, or- nullto indicate that this- UIComponentdoes not have a component identifier
- Throws:
- IllegalArgumentException- if- idis not syntactically valid
 
- 
getParentReturn the parent UIComponentof thisUIComponent, if any. A component must allow child components to be added to and removed from the list of children of this component, even though the child component returns null fromgetParent( ).- Returns:
- the parent component.
 
- 
setParentSet the parent UIComponentof thisUIComponent. Ifparent.isInView()returnstrue, calling this method will first cause aPreRemoveFromViewEventto be published, for this node, and then the children of this node. Then, once the re-parenting has occurred, aPostAddToViewEventwill be published as well, first for this node, and then for the node's children, but only if any of the following conditions are true.- 
 FacesContext.getCurrentPhaseId()returnsPhaseId.RESTORE_VIEWand partial state saving is enabled.
- 
 FacesContext.isPostback()returnsfalseandFacesContext.getCurrentPhaseId()returns something other thanPhaseId.RESTORE_VIEW
 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 childListor facetMap.- Parameters:
- parent- The new parent, or- nullfor the root node of a component tree
 
- 
 
- 
isRenderedpublic abstract boolean isRendered()Return trueif this component (and its children) should be rendered during the Render Response phase of the request processing lifecycle.- Returns:
- trueif the component should be rendered,- falseotherwise.
 
- 
setRenderedpublic abstract void setRendered(boolean rendered) Set the renderedproperty of thisUIComponent.- Parameters:
- rendered- If- truerender this component; otherwise, do not render this component
 
- 
getRendererTypeReturn the Renderertype for thisUIComponent(if any).- Returns:
- the renderer type.
 
- 
setRendererTypeSet the Renderertype for thisUIComponent, ornullfor components that render themselves.- Parameters:
- rendererType- Logical identifier of the type of- Rendererto use, or- nullfor components that render themselves
 
- 
getRendersChildrenpublic 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 callsRenderer.getRendersChildren()and returns the result. If it doesn't, it returns false. As of version 1.2 of the Jakarta Faces Specification, component authors are encouraged to returntruefrom this method and rely onUIComponentBase.encodeChildren(jakarta.faces.context.FacesContext).- Returns:
- trueif the component renders its children,- falseotherwise.
 
- 
getResourceBundleMapReturn a Map<String,String>of theResourceBundlefor this component. A component may have aResourceBundleassociated with it. This bundle may contain localized properties relating to instances of this component. The default implementation first looks for aResourceBundlewith a base name equal to the fully qualified class name of the currentUIComponent thisandLocaleequal to theLocaleof the currentUIViewRoot. If no such bundle is found, and the component is a composite component, let resourceName be the resourceName of theResourcefor this composite component, replacing the file extension with ".properties". Let libraryName be the libraryName of the theResourcefor this composite component. CallResourceHandler.createResource(java.lang.String,java.lang.String), passing the derived resourceName and libraryName. Note that this will automatically allow for the localization of theResourceBundledue to the localization facility implemented increateResource, which is specified in section 2.6.1.3 "Resource Identifiers" of the Jakarta Faces Specification Document. If the resultantResourceexists and can be found, theInputStreamfor the resource is used to create aResourceBundle. If either of the two previous steps for obtaining theResourceBundlefor this component is successful, theResourceBundleis wrapped in aMap<String,String>and returned. OtherwiseCollections.EMPTY_MAPis returned.- Returns:
- the resource bundle map.
- Since:
- 2.0
 
- 
getChildrenReturn a mutable Listrepresenting the childUIComponents associated with this component. The returned implementation must support all of the standard and optionalListmethods, plus support the following additional requirements:- The Listimplementation must implement thejava.io.Serializableinterface.
- Any attempt to add a nullmust throw a NullPointerException
- Any attempt to add an object that does not implement UIComponentmust throw a ClassCastException.
- Whenever a new child component is added, the parentproperty of the child must be set to this component instance. If theparentproperty of the child was already non-null, the child must first be removed from its previous parent (where it may have been either a child or a facet).
- Whenever an existing child component is removed, the parentproperty of the child must be set tonull.
- 
 After the child component has been added to the view, Application.publishEvent(jakarta.faces.context.FacesContext, java.lang.Class<? extends jakarta.faces.event.SystemEvent>, java.lang.Object)must be called, passingPostAddToViewEvent.classas the first argument and the newly added component as the second argument if any the following cases are true.- 
 FacesContext.getCurrentPhaseId()returnsPhaseId.RESTORE_VIEWand partial state saving is enabled.
- 
 FacesContext.isPostback()returnsfalseandFacesContext.getCurrentPhaseId()returns something other thanPhaseId.RESTORE_VIEW
 
- 
 
 - Returns:
- the list of children.
 
- The 
- 
getChildCountpublic abstract int getChildCount()Return the number of child UIComponents that are associated with thisUIComponent. If there are no children, this method must return 0. The method must not cause the creation of a child component list.- Returns:
- the number of child components.
 
- 
findComponentSearch for and return the UIComponentwith anidthat matches the specified search expression (if any), according to the algorithm described below.WARNING: The found UIComponentinstance, if any, is returned without regard for its tree traversal context. Retrieving an Jakarta Expression Language-bound attribute from the component is not safe. Jakarta Expression Language expressions can contain implicit objects, such as#{component}, which assume they are being evaluated within the scope of a tree traversal context. Evaluating expressions with these kinds of implicit objects outside of a tree traversal context produces undefined results. SeeinvokeOnComponent(jakarta.faces.context.FacesContext, java.lang.String, jakarta.faces.component.ContextCallback)for a method that does correctly account for the tree traversal context when operating on the foundUIComponentinstance.invokeOnComponent(jakarta.faces.context.FacesContext, java.lang.String, jakarta.faces.component.ContextCallback)is also useful to find components given a simpleclientId.Component identifiers are required to be unique within the scope of the closest ancestor NamingContainerthat encloses this component (which might be this component itself). If there are noNamingContainercomponents in the ancestry of this component, the root component in the tree is treated as if it were aNamingContainer, whether or not its class actually implements theNamingContainerinterface.A search expression consists of either an identifier (which is matched exactly against the idproperty of aUIComponent, or a series of such identifiers linked by theUINamingContainer.getSeparatorChar(jakarta.faces.context.FacesContext)character value. The search algorithm should operates as follows, though alternate alogrithms may be used as long as the end result is the same:- Identify the UIComponentthat will be the base for searching, by stopping as soon as one of the following conditions is met:- If the search expression begins with the the separator character (called an "absolute" search expression), the
 base will be the root UIComponentof the component tree. The leading separator character will be stripped off, and the remainder of the search expression will be treated as a "relative" search expression as described below.
- Otherwise, if this UIComponentis aNamingContainerit will serve as the basis.
- Otherwise, search up the parents of this component. If a NamingContaineris encountered, it will be the base.
- Otherwise (if no NamingContaineris encountered) the rootUIComponentwill be the base.
 
- If the search expression begins with the the separator character (called an "absolute" search expression), the
 base will be the root 
- The search expression (possibly modified in the previous step) is now a "relative" search expression that will be
 used to locate the component (if any) that has an idthat matches, within the scope of the base component. The match is performed as follows:- If the search expression is a simple identifier, this value is compared to the idproperty, and then recursively through the facets and children of the baseUIComponent(except that if a descendantNamingContaineris found, its own facets and children are not searched).
- If the search expression includes more than one identifier separated by the separator character, the first
 identifier is used to locate a NamingContainerby the rules in the previous bullet point. Then, thefindComponent()method of thisNamingContainerwill be called, passing the remainder of the search expression.
 
- If the search expression is a simple identifier, this value is compared to the 
 - Parameters:
- expr- Search expression identifying the- UIComponentto be returned
- Returns:
- the found UIComponent, ornullif the component was not found.
- Throws:
- IllegalArgumentException- if an intermediate identifier in a search expression identifies a- UIComponentthat is not a- NamingContainer
- NullPointerException- if- expris- null
 
- Identify the 
- 
invokeOnComponentpublic boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback) throws FacesException Starting at this component in the View hierarchy, search for a component with a clientIdequal to the argumentclientIdand, if found, call theContextCallback.invokeContextCallback(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent)method on the argumentcallback, passing the currentFacesContextand the found component as arguments. This method is similar tofindComponent(java.lang.String)but it does not support the leadingUINamingContainer.getSeparatorChar(jakarta.faces.context.FacesContext)syntax for searching from the root of the View.The default implementation will first check if this.getClientId()is equal to the argumentclientId. If so, first callpushComponentToEL(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent), then call theContextCallback.invokeContextCallback(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent)method on the argument callback, passing through theFacesContextargument and passing this as the component argument. Then callpopComponentFromEL(jakarta.faces.context.FacesContext). If anExceptionis thrown by the callback, wrap it in aFacesExceptionand re-throw it. Otherwise, returntrue.Otherwise, for each component returned by getFacetsAndChildren(), callinvokeOnComponent()passing the arguments to this method, in order. The first timeinvokeOnComponent()returns true, abort traversing the rest of theIteratorand returntrue.When calling ContextCallback.invokeContextCallback(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent)the implementation of this method must guarantee that the state of the component passed to the callback correctly reflects the component's position in the View hierarchy with respect to any state found in the argumentclientId. For example, an iterating component such asUIDatawill need to set its row index to correctly reflect the argumentclientIdbefore finding the appropriate child component backed by the correct row. When the callback returns, either normally or by throwing anExceptionthe implementation of this method must restore the state of the view to the way it was before invoking the callback.If none of the elements from getFacetsAndChildren()returnedtruefrominvokeOnComponent(), returnfalse.Simple usage example to find a component by clientId.private UIComponent found = null; private void doFind(FacesContext context, String clientId) { context.getViewRoot().invokeOnComponent(context, clientId, new ContextCallback() { public void invokeContextCallback(FacesContext context, UIComponent component) { found = component; } }); }- Parameters:
- context- the- FacesContextfor the current request
- clientId- the client identifier of the component to be passed to the argument callback.
- callback- an implementation of the Callback interface.
- Returns:
- trueif the a component with the given- clientIdis found, the callback method was successfully invoked passing that component as an argument, and no Exception was thrown. Returns- falseif no component with the given- clientIdis found.
- Throws:
- NullPointerException- if any of the arguments are null
- FacesException- if the argument Callback throws an Exception, it is wrapped in a- FacesExceptionand re-thrown.
- Since:
- 1.2
 
- 
getFacetsReturn a mutable Maprepresenting the facetUIComponents associated with thisUIComponent, keyed by facet name (which must be a String). The returned implementation must support all of the standard and optionalMapmethods, plus support the following additional requirements:- The Mapimplementation must implement thejava.io.Serializableinterface.
- Any attempt to add a nullkey or value must throw a NullPointerException.
- Any attempt to add a key that is not a String must throw a ClassCastException.
- Any attempt to add a value that is not a UIComponentmust throw a ClassCastException.
- Whenever a new facet UIComponentis added:- The parentproperty of the component must be set to this component instance.
- If the parentproperty of the component was already non-null, the component must first be removed from its previous parent (where it may have been either a child or a facet).
 
- The 
- Whenever an existing facet UIComponentis removed:- The parentproperty of the facet must be set tonull.
 
- The 
 - Returns:
- the map of facets.
 
- The 
- 
getFacetCountpublic int getFacetCount()Return the number of facet UIComponents that are associated with thisUIComponent. If there are no facets, this method must return 0. The method must not cause the creation of a facet component map.For backwards compatability with classes that extend UIComponent directly, a default implementation is provided that simply calls getFacets()and then calls thesize()method on the returnedMap. A more optimized version of this method is provided inUIComponentBase.getFacetCount().- Returns:
- the number of facets.
- Since:
- 1.2
 
- 
getFacetConvenience method to return the named facet, if it exists, or nullotherwise. If the requested facet does not exist, the facets Map must not be created.- Parameters:
- name- Name of the desired facet
- Returns:
- the component, or null.
 
- 
getFacetsAndChildrenReturn an Iteratorover the facet followed by childUIComponents of thisUIComponent. 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 emptyIteratoris returned.The returned Iteratormust not support theremove()operation.- Returns:
- the facets and children iterator.
 
- 
broadcastBroadcast the specified FacesEventto 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.If the eventis an instance ofBehaviorEventand the currentcomponentis the source of theeventcallBehaviorEvent.getBehavior()to get theBehaviorfor the event. CallBehavior.broadcast(jakarta.faces.event.BehaviorEvent)on theBehaviorinstance.- Parameters:
- event- The- FacesEventto be broadcast
- Throws:
- AbortProcessingException- Signal the Jakarta Faces implementation that no further processing on the current event should be performed
- IllegalArgumentException- if the implementation class of this- FacesEventis not supported by this component
- NullPointerException- if- eventis- null
 
- 
decodeDecode any new state of this UIComponentfrom the request contained in the specifiedFacesContext, 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-- FacesContextfor the request we are processing
- Throws:
- NullPointerException- if- contextis- null
 
- 
visitTreePerform a tree visit starting at this node in the tree. UIComponent.visitTree() implementations do not invoke the VisitCallbackdirectly, but instead callVisitContext.invokeVisitCallback(jakarta.faces.component.UIComponent, jakarta.faces.component.visit.VisitCallback)to invoke the callback. This allowsVisitContextimplementations to provide optimized tree traversals, for example by only calling theVisitCallbackfor a subset of components.UIComponent.visitTree() implementations must call UIComponent.pushComponentToEL() before performing the visit and UIComponent.popComponentFromEL() after the visit. - Parameters:
- visitContext- the- VisitContextfor this visit
- callback- the- VisitCallbackinstance whose- visitmethod will be called for each node visited.
- Returns:
- component implementations may return trueto 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.
- Since:
- 2.0
- See Also:
 
- 
isVisitableReturn trueif this component should be visited,falseotherwise. Called byUIComponent.visitTree()to determine whether this component satisfies the hints returned byVisitContext.getHints().If this method returns false, the tree visited is short-circuited such that neither the component nor any of its descendents will be visited Custom visitTree()implementations may call this method to determine whether the component is visitable before performing any visit-related processing.- Parameters:
- context- the Visit context.
- Returns:
- trueif visitable,- falseotherwise.
- Since:
- 2.0
 
- 
encodeBeginIf our renderedproperty istrue, render the beginning of the current state of thisUIComponentto the response contained in the specifiedFacesContext. CallpushComponentToEL(jakarta.faces.context.FacesContext,jakarta.faces.component.UIComponent). CallApplication.publishEvent(jakarta.faces.context.FacesContext, java.lang.Class<? extends jakarta.faces.event.SystemEvent>, java.lang.Object), passingPreRenderComponentEvent.classas the first argument and the component instance to be rendered as the second argument.If a Rendereris associated with thisUIComponent, the actual encoding will be delegated toRenderer.encodeBegin(FacesContext, UIComponent).If our renderedproperty isfalse, callpushComponentToEL(jakarta.faces.context.FacesContext,jakarta.faces.component.UIComponent)and return immediately.- Parameters:
- context-- FacesContextfor the response we are creating
- Throws:
- IOException- if an input/output error occurs while rendering
- NullPointerException- if- contextis- null
 
- 
encodeChildrenIf our renderedproperty istrue, render the childUIComponents of thisUIComponent. This method will only be called if therendersChildrenproperty istrue.If a Rendereris associated with thisUIComponent, the actual encoding will be delegated toRenderer.encodeChildren(FacesContext, UIComponent). If noRendereris associated with thisUIComponent, iterate over each of the children of this component and callencodeAll(jakarta.faces.context.FacesContext).- Parameters:
- context-- FacesContextfor the response we are creating
- Throws:
- IOException- if an input/output error occurs while rendering
- NullPointerException- if- contextis- null
 
- 
encodeEndIf our renderedproperty istrue, render the ending of the current state of thisUIComponent.If a Rendereris associated with thisUIComponent, the actual encoding will be delegated toRenderer.encodeEnd(FacesContext, UIComponent).Call popComponentFromEL(jakarta.faces.context.FacesContext). before returning regardless of the value of therenderedproperty.- Parameters:
- context-- FacesContextfor the response we are creating
- Throws:
- IOException- if an input/output error occurs while rendering
- NullPointerException- if- contextis- null
 
- 
encodeAllIf this component returns truefromisRendered(), take the following action.Render this component and all its children that return truefromisRendered(), regardless of the value of thegetRendersChildren()flag.- Parameters:
- context- the Faces context.
- Throws:
- IOException- if an input/output error occurs while rendering
- NullPointerException- if- contextis- null
- Since:
- 1.2
 
- 
pushComponentToELPush the current UIComponentthisto theFacesContextattribute map saving the previousUIComponentfor a subsequent call topopComponentFromEL(jakarta.faces.context.FacesContext).This method and popComponentFromEL()form the basis for the contract that enables the Jakarta Expression Language Expression "#{component}" to resolve to the "current" component that is being processed in the lifecycle. The requirements for whenpushComponentToEL()andpopComponentFromEL()must be called are specified as needed in the javadoc for this class.After pushComponentToEL()returns, a call togetCurrentComponent(jakarta.faces.context.FacesContext)must returnthisUIComponentinstance untilpopComponentFromEL()is called, after which point the previousUIComponentinstance will be returned fromgetCurrentComponent()- Parameters:
- context- the- FacesContextfor the current request
- component- the- componentto push to the EL. If- componentis- nullthe- UIComponentinstance that this call was invoked upon will be pushed to the EL.
- Throws:
- NullPointerException- if- contextis- null
- Since:
- 2.0
- See Also:
 
- 
popComponentFromELPop the current UIComponentfrom theFacesContextattributes map so that the previousUIComponent, if any, becomes the current component.- Parameters:
- context- the- FacesContextfor the current request
- Throws:
- NullPointerException- if- contextis- null
- Since:
- 2.0
- See Also:
 
- 
isCompositeComponentReturn trueifcomponentis a composite component, otherwisefalse.- Parameters:
- component- the- UIComponentto test
- Returns:
- trueif this is a composite component,- falseotherwise.
- Throws:
- NullPointerException- if- componentis- null
- Since:
- 2.0
 
- 
getCompositeComponentParentFinds the nearest composite component parent of the specified component. - Parameters:
- component- the component from which to start the search from
- Returns:
- if componentisnull, returnnull, otherwise search the component's parent hierachy for the nearest parent composite component. If no parent composite component is found, returnnull
- Since:
- 2.0
 
- 
getCurrentComponentReturn the UIComponentinstance that is currently processing. This is equivalent to evaluating the Jakarta Expression Language expression "#{component}" and doing agetValueoperation on the resultantValueExpression.This method must return nullif there is no currently processingUIComponent- Parameters:
- context-- FacesContextfor the request we are processing
- Returns:
- the current component, or null.
- Throws:
- NullPointerException- if- contextis- null
- Since:
- 2.0
 
- 
getCurrentCompositeComponentReturn the closest ancestor component, relative to the component returned from getCurrentComponent(jakarta.faces.context.FacesContext), that is a composite component, ornullif no such component exists.- Parameters:
- context-- FacesContextfor the request we are processing
- Returns:
- the current composite component, or null.
- Throws:
- NullPointerException- if- contextis- null
- Since:
- 2.0
 
- 
addFacesListenerAdd the specified FacesListenerto the set of listeners registered to receive event notifications from thisUIComponent. It is expected thatUIComponentclasses 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- FacesListenerto be registered
- Throws:
- NullPointerException- if- listeneris- null
 
- 
getFacesListenersReturn 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 ofclazz.- Parameters:
- clazz- Class that must be implemented by a- FacesListenerfor it to be returned
- Returns:
- the Faces listeners, or a zero-length array.
- Throws:
- IllegalArgumentException- if- classis not, and does not implement,- FacesListener
- NullPointerException- if- clazzis- null
 
- 
removeFacesListenerRemove the specified FacesListenerfrom the set of listeners registered to receive event notifications from thisUIComponent.- Parameters:
- listener- The- FacesListenerto be deregistered
- Throws:
- NullPointerException- if- listeneris- null
 
- 
queueEventQueue an event for broadcast at the end of the current request processing lifecycle phase. The default implementation in UIComponentBasemust delegate this call to thequeueEvent()method of the parentUIComponent.- Parameters:
- event-- FacesEventto be queued
- Throws:
- IllegalStateException- if this component is not a descendant of a- UIViewRoot
- NullPointerException- if- eventis- null
 
- 
subscribeToEventpublic void subscribeToEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener) This implementation throws UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.UIComponentBaseprovides the implementation of this method.- Parameters:
- eventClass- the event class.
- componentListener- the listener.
- Since:
- 2.1
 
- 
unsubscribeFromEventpublic void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener) This implementation throws UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.UIComponentBaseprovides the implementation of this method.- Parameters:
- eventClass- the event class.
- componentListener- the component listener.
- Since:
- 2.1
 
- 
getListenersForEventClassThis implementation throws UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.UIComponentBaseprovides the implementation of this method.- Specified by:
- getListenersForEventClassin interface- SystemEventListenerHolder
- Parameters:
- eventClass- the event class.
- Returns:
- the list of listeners, never null.
- Since:
- 2.1
 
- 
getNamingContainerStarting with "this", return the closest component in the ancestry that is a NamingContainerornullif none can be found.- Returns:
- the naming container, or null.
- Since:
- 2.0
 
- 
processRestoreStatePerform 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. - Call the restoreState()method of this component.
- Call pushComponentToEL(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent).
- Call the processRestoreState()method of all facets and children of thisUIComponentin the order determined by a call togetFacetsAndChildren(). After returning from theprocessRestoreState()method on a child or facet, callpopComponentFromEL(jakarta.faces.context.FacesContext)
 This method may not be called if the state saving method is set to server. - Parameters:
- context-- FacesContextfor the request we are processing
- state- the state.
- Throws:
- NullPointerException- if- contextis- null
 
- Call the 
- 
processDecodesPerform 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. - If the renderedproperty of thisUIComponentisfalse, skip further processing.
- Call pushComponentToEL(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent).
- Call the processDecodes()method of all facets and children of thisUIComponent, in the order determined by a call togetFacetsAndChildren().
- Call the decode()method of this component.
- Call popComponentFromEL(jakarta.faces.context.FacesContext)from inside of afinally block, just before returning.
- If a RuntimeExceptionis thrown during decode processing, callFacesContext.renderResponse()and re-throw the exception.
 - Parameters:
- context-- FacesContextfor the request we are processing
- Throws:
- NullPointerException- if- contextis- null
 
- If the 
- 
processEventThe default implementation performs the following action. If the argument eventis an instance ofPostRestoreStateEvent, callthis.getValueExpression(java.lang.String)passing the literal string “binding”, without the quotes, as the argument. If the result is non-null, set the value of theValueExpressionto bethis.- Specified by:
- processEventin interface- ComponentSystemEventListener
- Parameters:
- event- the- ComponentSystemEventinstance that is being processed.
- Throws:
- AbortProcessingException- if lifecycle processing should cease for this request.
 
- 
processValidatorsPerform 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. - If the renderedproperty of thisUIComponentisfalse, skip further processing.
- Call pushComponentToEL(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent).
- Call the processValidators()method of all facets and children of thisUIComponent, in the order determined by a call togetFacetsAndChildren().
- After returning from calling getFacetsAndChildren()callpopComponentFromEL(jakarta.faces.context.FacesContext).
 - Parameters:
- context-- FacesContextfor the request we are processing
- Throws:
- NullPointerException- if- contextis- null
- See Also:
 
- If the 
- 
processUpdatesPerform 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. - If the renderedproperty of thisUIComponentisfalse, skip further processing.
- Call pushComponentToEL(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent).
- Call the processUpdates()method of all facets and children of thisUIComponent, in the order determined by a call togetFacetsAndChildren(). After returning from theprocessUpdates()method on a child or facet, callpopComponentFromEL(jakarta.faces.context.FacesContext)
 - Parameters:
- context-- FacesContextfor the request we are processing
- Throws:
- NullPointerException- if- contextis- null
 
- If the 
- 
processSaveStatePerform 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. - consult the transientproperty of this component. If true, just returnnull.
- Call pushComponentToEL(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent).
- Call the processSaveState()method of all facets and children of thisUIComponentin the order determined by a call togetFacetsAndChildren(), skipping children and facets that are transient. Ensure thatpopComponentFromEL(jakarta.faces.context.FacesContext)is called correctly after each child or facet.
- Call the saveState()method of this component.
- Encapsulate the child state and your state into a Serializable Object and return it.
 This method may not be called if the state saving method is set to server. - Parameters:
- context-- FacesContextfor the request we are processing
- Returns:
- the saved state.
- Throws:
- NullPointerException- if- contextis- null
 
- consult the 
- 
getFacesContextConvenience method to return the FacesContextinstance for the current request.- Returns:
- the Faces context.
 
- 
getRendererConvenience method to return the Rendererinstance associated with this component, if any; otherwise, returnnull.- Parameters:
- context-- FacesContextfor the current request
- Returns:
- the renderer, or null.
 
 
-