javax.faces.component
Class UIComponent

java.lang.Object
  extended by javax.faces.component.UIComponent
All Implemented Interfaces:
EventListener, PartialStateHolder, StateHolder, TransientStateHolder, ComponentSystemEventListener, FacesListener, SystemEventListenerHolder
Direct Known Subclasses:
UIComponentBase

@JSFComponent(type="javax.faces.Component",
              family="javax.faces.Component",
              desc="abstract base component",
              configExcluded=true)
public abstract class UIComponent
extends Object
implements PartialStateHolder, TransientStateHolder, SystemEventListenerHolder, ComponentSystemEventListener

see Javadoc of J SF Specification


Field Summary
static String ATTRS_WITH_DECLARED_DEFAULT_VALUES
           
static String BEANINFO_KEY
          Constant used in component attribute map to retrieve the BeanInfo of a composite component.
protected  Map<String,javax.el.ValueExpression> bindings
          Deprecated.  
static String COMPOSITE_COMPONENT_TYPE_KEY
          Constant used in BeanInfo descriptor as a key for retrieve an alternate component type for create the composite base component.
static String COMPOSITE_FACET_NAME
          Constant used to define the facet inside this component that store the component hierarchy generated by a composite component implementation, and then rendered.
static String CURRENT_COMPONENT
          Constant used to store the current component that is being processed.
static String CURRENT_COMPOSITE_COMPONENT
          Constant used to store the current composite component that is being processed.
static String FACETS_KEY
          This constant has two usages.
static String HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME
          Indicate if the facesContext attribute values under the keys javax.faces.component.CURRENT_COMPONENT and javax.faces.component.CURRENT_COMPOSITE_COMPONENT should be valid or not.
static String VIEW_LOCATION_KEY
          Constant used in component attribute map to store the Location object where the definition of this component is.
 
Constructor Summary
UIComponent()
           
 
Method Summary
protected abstract  void addFacesListener(FacesListener listener)
           
abstract  void broadcast(FacesEvent event)
           
 void clearInitialState()
          
abstract  void decode(FacesContext context)
           
 void encodeAll(FacesContext context)
           
abstract  void encodeBegin(FacesContext context)
           
abstract  void encodeChildren(FacesContext context)
           
abstract  void encodeEnd(FacesContext context)
           
abstract  UIComponent findComponent(String expr)
           
abstract  Map<String,Object> getAttributes()
           
abstract  int getChildCount()
           
abstract  List<UIComponent> getChildren()
           
 String getClientId()
           
abstract  String getClientId(FacesContext context)
           
static UIComponent getCompositeComponentParent(UIComponent component)
          search for the nearest parent composite component, if no parent is found it has to return null! if the component itself is null we have to return null as well!
 String getContainerClientId(FacesContext ctx)
           
static UIComponent getCurrentComponent(FacesContext context)
           
static UIComponent getCurrentCompositeComponent(FacesContext context)
           
protected abstract  FacesContext getFacesContext()
           
protected abstract  FacesListener[] getFacesListeners(Class clazz)
           
abstract  UIComponent getFacet(String name)
           
 int getFacetCount()
           
abstract  Map<String,UIComponent> getFacets()
           
abstract  Iterator<UIComponent> getFacetsAndChildren()
           
abstract  String getFamily()
           
abstract  String getId()
           
 List<SystemEventListener> getListenersForEventClass(Class<? extends SystemEvent> eventClass)
           
 UIComponent getNamingContainer()
           
abstract  UIComponent getParent()
          Returns the parent of the component.
 Map<String,Object> getPassThroughAttributes()
           
abstract  Map<String,Object> getPassThroughAttributes(boolean create)
           
protected abstract  Renderer getRenderer(FacesContext context)
           
abstract  String getRendererType()
           
abstract  boolean getRendersChildren()
           
 Map<String,String> getResourceBundleMap()
           
protected  StateHelper getStateHelper()
           
protected  StateHelper getStateHelper(boolean create)
          returns a delta state saving enabled state helper for the current component
 TransientStateHelper getTransientStateHelper()
           
 TransientStateHelper getTransientStateHelper(boolean create)
           
abstract  ValueBinding getValueBinding(String name)
          Deprecated. Replaced by getValueExpression
 javax.el.ValueExpression getValueExpression(String name)
           
 boolean initialStateMarked()
          
 boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
          Invokes the invokeContextCallback method with the component, specified by clientId.
static boolean isCompositeComponent(UIComponent component)
           
 boolean isInView()
          Indicate if this component is inside a view, or in other words is contained by an UIViewRoot instance (which represents the view).
abstract  boolean isRendered()
           
protected  boolean isVisitable(VisitContext context)
          This method indicates if a component is visitable according to the hints passed by the VisitContext parameter! This method internally is used by visitTree and if it returns false it short circuits the visitTree execution.
 void markInitialState()
           
 void popComponentFromEL(FacesContext context)
           
abstract  void processDecodes(FacesContext context)
           
 void processEvent(ComponentSystemEvent event)
           
abstract  void processRestoreState(FacesContext context, Object state)
           
abstract  Object processSaveState(FacesContext context)
           
abstract  void processUpdates(FacesContext context)
           
abstract  void processValidators(FacesContext context)
           
 void pushComponentToEL(FacesContext context, UIComponent component)
           
abstract  void queueEvent(FacesEvent event)
           
protected abstract  void removeFacesListener(FacesListener listener)
           
 void restoreTransientState(FacesContext context, Object state)
          Restore the "transient state" using the object passed as state.
 Object saveTransientState(FacesContext context)
          Return the object containing related "transient states".
abstract  void setId(String id)
           
 void setInView(boolean isInView)
          Define if the component is on the view or not.
abstract  void setParent(UIComponent parent)
          For JSF-framework internal use only.
abstract  void setRendered(boolean rendered)
           
abstract  void setRendererType(String rendererType)
           
abstract  void setValueBinding(String name, ValueBinding binding)
          Deprecated. Replaced by setValueExpression
 void setValueExpression(String name, javax.el.ValueExpression expression)
           
 void subscribeToEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener)
           
 void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener)
           
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.StateHolder
isTransient, restoreState, saveState, setTransient
 

Field Detail

BEANINFO_KEY

public static final String BEANINFO_KEY
Constant used in component attribute map to retrieve the BeanInfo of a composite component.

See Also:
ViewDeclarationLanguage.getComponentMetadata(FacesContext, Resource), ViewDeclarationLanguage.retargetAttachedObjects(FacesContext, UIComponent, List), ViewDeclarationLanguage.retargetMethodExpressions(FacesContext, UIComponent), Application.createComponent(FacesContext, Resource), Constant Field Values

COMPOSITE_COMPONENT_TYPE_KEY

public static final String COMPOSITE_COMPONENT_TYPE_KEY
Constant used in BeanInfo descriptor as a key for retrieve an alternate component type for create the composite base component.

See Also:
Application.createComponent(FacesContext, Resource), Constant Field Values

COMPOSITE_FACET_NAME

public static final String COMPOSITE_FACET_NAME
Constant used to define the facet inside this component that store the component hierarchy generated by a composite component implementation, and then rendered. In other words, note that direct children of a component are not rendered, instead components inside this face are rendered.

See Also:
Constant Field Values

CURRENT_COMPONENT

public static final String CURRENT_COMPONENT
Constant used to store the current component that is being processed.

See Also:
pushComponentToEL(FacesContext, UIComponent), popComponentFromEL(FacesContext), Constant Field Values

CURRENT_COMPOSITE_COMPONENT

public static final String CURRENT_COMPOSITE_COMPONENT
Constant used to store the current composite component that is being processed.

See Also:
pushComponentToEL(FacesContext, UIComponent), popComponentFromEL(FacesContext), Constant Field Values

FACETS_KEY

public static final String FACETS_KEY
This constant has two usages. The first one is in component attribute map to identify the facet name under this component is child of its parent. The second one is on BeanInfo descriptor as a key for a Map<String, PropertyDescriptor> that contains metadata information defined by composite:facet tag and composite:implementation(because this one fills the facet referenced by COMPOSITE_FACET_NAME constant).

See Also:
Constant Field Values

VIEW_LOCATION_KEY

public static final String VIEW_LOCATION_KEY
Constant used in component attribute map to store the Location object where the definition of this component is.

See Also:
Constant Field Values

ATTRS_WITH_DECLARED_DEFAULT_VALUES

public static final String ATTRS_WITH_DECLARED_DEFAULT_VALUES
See Also:
Constant Field Values

HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME

@JSFWebConfigParam(since="2.1.0",
                   expectedValues="true, false",
                   defaultValue="false")
public static final String HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME
Indicate if the facesContext attribute values under the keys javax.faces.component.CURRENT_COMPONENT and javax.faces.component.CURRENT_COMPOSITE_COMPONENT should be valid or not. By default, those keys are deprecated since 2.1

See Also:
Constant Field Values

bindings

@Deprecated
protected Map<String,javax.el.ValueExpression> bindings
Deprecated. 
Constructor Detail

UIComponent

public UIComponent()
Method Detail

getAttributes

public abstract Map<String,Object> getAttributes()

getPassThroughAttributes

public final Map<String,Object> getPassThroughAttributes()
Returns:
Since:
2.2

getPassThroughAttributes

public abstract Map<String,Object> getPassThroughAttributes(boolean create)
Parameters:
create -
Returns:
Since:
2.2

initialStateMarked

public boolean initialStateMarked()

Specified by:
initialStateMarked in interface PartialStateHolder
Since:
2.0

invokeOnComponent

public boolean invokeOnComponent(FacesContext context,
                                 String clientId,
                                 ContextCallback callback)
                          throws FacesException
Invokes the invokeContextCallback method with the component, specified by clientId.

Parameters:
context - FacesContext for the current request
clientId - the id of the desired UIComponent clazz
callback - Implementation of the ContextCallback to be called
Returns:
has component been found ?
Throws:
FacesException

isCompositeComponent

public static boolean isCompositeComponent(UIComponent component)
Parameters:
component -
Returns:
true if the component is a composite component otherwise false is returned
Throws:
NullPointerException - if the component is null
Since:
2.0

isInView

public boolean isInView()
Indicate if this component is inside a view, or in other words is contained by an UIViewRoot instance (which represents the view). If this component is a UIViewRoot instance, the components "always" is on the view. By default it is false but for UIViewRoot instances is true.

Returns:
Since:
2.0

isRendered

public abstract boolean isRendered()

markInitialState

public void markInitialState()
Specified by:
markInitialState in interface PartialStateHolder

isVisitable

protected boolean isVisitable(VisitContext context)
This method indicates if a component is visitable according to the hints passed by the VisitContext parameter! This method internally is used by visitTree and if it returns false it short circuits the visitTree execution.

Parameters:
context -
Returns:
Since:
2.0

setValueBinding

public abstract void setValueBinding(String name,
                                     ValueBinding binding)
Deprecated. Replaced by setValueExpression


setValueExpression

public void setValueExpression(String name,
                               javax.el.ValueExpression expression)

getClientId

public String getClientId()

getClientId

public abstract String getClientId(FacesContext context)

getCompositeComponentParent

public static UIComponent getCompositeComponentParent(UIComponent component)
search for the nearest parent composite component, if no parent is found it has to return null! if the component itself is null we have to return null as well!

Parameters:
component - the component to start from
Returns:
the parent composite component if found otherwise null
Since:
2.0

getContainerClientId

public String getContainerClientId(FacesContext ctx)
Since:
1.2

getCurrentComponent

public static UIComponent getCurrentComponent(FacesContext context)
Parameters:
context -
Returns:
Since:
2.0

getCurrentCompositeComponent

public static UIComponent getCurrentCompositeComponent(FacesContext context)
Parameters:
context -
Returns:
Since:
2.0

getFamily

public abstract String getFamily()

getId

public abstract String getId()

getListenersForEventClass

public List<SystemEventListener> getListenersForEventClass(Class<? extends SystemEvent> eventClass)
Specified by:
getListenersForEventClass in interface SystemEventListenerHolder

getNamingContainer

public UIComponent getNamingContainer()
Returns:
Since:
2.0

setId

public abstract void setId(String id)

setInView

public void setInView(boolean isInView)
Define if the component is on the view or not.

This value is set in the following conditions:


setParent

public abstract void setParent(UIComponent parent)
For JSF-framework internal use only. Don't call this method to add components to the component tree. Use parent.getChildren().add(child) instead.


getParent

public abstract UIComponent getParent()
Returns the parent of the component. Children can be added to or removed from a component even if this method returns null for the child.


setRendered

public abstract void setRendered(boolean rendered)

getRendererType

public abstract String getRendererType()

setRendererType

public abstract void setRendererType(String rendererType)

getRendersChildren

public abstract boolean getRendersChildren()

getResourceBundleMap

public Map<String,String> getResourceBundleMap()

getValueBinding

public abstract ValueBinding getValueBinding(String name)
Deprecated. Replaced by getValueExpression


getValueExpression

public javax.el.ValueExpression getValueExpression(String name)

getChildren

public abstract List<UIComponent> getChildren()

getChildCount

public abstract int getChildCount()

findComponent

public abstract UIComponent findComponent(String expr)

getFacets

public abstract Map<String,UIComponent> getFacets()

getFacet

public abstract UIComponent getFacet(String name)

getFacetsAndChildren

public abstract Iterator<UIComponent> getFacetsAndChildren()

broadcast

public abstract void broadcast(FacesEvent event)
                        throws AbortProcessingException
Throws:
AbortProcessingException

clearInitialState

public void clearInitialState()

Specified by:
clearInitialState in interface PartialStateHolder
Since:
2.0

decode

public abstract void decode(FacesContext context)

encodeBegin

public abstract void encodeBegin(FacesContext context)
                          throws IOException
Throws:
IOException

encodeChildren

public abstract void encodeChildren(FacesContext context)
                             throws IOException
Throws:
IOException

encodeEnd

public abstract void encodeEnd(FacesContext context)
                        throws IOException
Throws:
IOException

encodeAll

public void encodeAll(FacesContext context)
               throws IOException
Throws:
IOException

addFacesListener

protected abstract void addFacesListener(FacesListener listener)

getFacesListeners

protected abstract FacesListener[] getFacesListeners(Class clazz)

removeFacesListener

protected abstract void removeFacesListener(FacesListener listener)

queueEvent

public abstract void queueEvent(FacesEvent event)

processRestoreState

public abstract void processRestoreState(FacesContext context,
                                         Object state)

processDecodes

public abstract void processDecodes(FacesContext context)

processEvent

public void processEvent(ComponentSystemEvent event)
                  throws AbortProcessingException
Specified by:
processEvent in interface ComponentSystemEventListener
Throws:
AbortProcessingException

processValidators

public abstract void processValidators(FacesContext context)

processUpdates

public abstract void processUpdates(FacesContext context)

processSaveState

public abstract Object processSaveState(FacesContext context)

subscribeToEvent

public void subscribeToEvent(Class<? extends SystemEvent> eventClass,
                             ComponentSystemEventListener componentListener)

unsubscribeFromEvent

public void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass,
                                 ComponentSystemEventListener componentListener)

visitTree

public 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

there 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

Parameters:
context - the visit context which handles the processing details
callback - the callback to be performed
Returns:
false if the processing is not done true if we can shortcut the visiting because we are done with everything
Since:
2.0

getFacesContext

protected abstract FacesContext getFacesContext()

getRenderer

protected abstract Renderer getRenderer(FacesContext context)

getStateHelper

protected StateHelper getStateHelper()

getStateHelper

protected StateHelper getStateHelper(boolean create)
returns a delta state saving enabled state helper for the current component

Parameters:
create - if true a state helper is created if not already existing
Returns:
an implementation of the StateHelper interface or null if none exists and create is set to false

getTransientStateHelper

public final TransientStateHelper getTransientStateHelper()

getTransientStateHelper

public TransientStateHelper getTransientStateHelper(boolean create)

restoreTransientState

public void restoreTransientState(FacesContext context,
                                  Object state)
Description copied from interface: TransientStateHolder

Restore the "transient state" using the object passed as state.

If the state argument is null clear any previous transient state if any and return.

Specified by:
restoreTransientState in interface TransientStateHolder
state - the object containing transient values

saveTransientState

public Object saveTransientState(FacesContext context)
Description copied from interface: TransientStateHolder

Return the object containing related "transient states". that could be used later to restore the "transient state".

Specified by:
saveTransientState in interface TransientStateHolder
Returns:
object containing transient values

popComponentFromEL

public final void popComponentFromEL(FacesContext context)

pushComponentToEL

public final void pushComponentToEL(FacesContext context,
                                    UIComponent component)

getFacetCount

public int getFacetCount()
Since:
1.2


Copyright © 2014 The Apache Software Foundation. All rights reserved.