public class BehaviorHolderWrapper
extends javax.faces.component.UIComponent
implements javax.faces.component.behavior.ClientBehaviorHolder
Constructor and Description |
---|
BehaviorHolderWrapper(javax.faces.component.UIComponent parent,
String virtualEvent,
String event) |
Modifier and Type | Method and Description |
---|---|
void |
addClientBehavior(String eventName,
javax.faces.component.behavior.ClientBehavior behavior)
Attaches a |
protected void |
addFacesListener(javax.faces.event.FacesListener listener)
Add the specified
FacesListener to the set of listeners
registered to receive event notifications from this UIComponent . |
void |
broadcast(javax.faces.event.FacesEvent event)
Broadcast the specified
FacesEvent to all registered
event listeners who have expressed an interest in events of this
type. |
void |
decode(javax.faces.context.FacesContext context)
Decode any new state of this
UIComponent from the
request contained in the specified FacesContext , and store
this state as needed. |
void |
encodeBegin(javax.faces.context.FacesContext context)
If our
rendered property is true , render the
beginning of the current state of this UIComponent to the
response contained in the specified FacesContext . |
void |
encodeChildren(javax.faces.context.FacesContext context)
If our
rendered property is true ,
render the child UIComponent s of this UIComponent . |
void |
encodeEnd(javax.faces.context.FacesContext context)
If our
rendered property is true , render the
ending of the current state of this UIComponent . |
javax.faces.component.UIComponent |
findComponent(String expr)
Search for and
return the
UIComponent with an id that
matches the specified search expression (if any), according to
the algorithm described below. |
Map<String,Object> |
getAttributes()
Return a mutable
Map representing the attributes
(and properties, see below) associated wth this UIComponent ,
keyed by attribute name (which must be a String). |
int |
getChildCount()
Return the number of child
UIComponent s that are
associated with this UIComponent . |
List<javax.faces.component.UIComponent> |
getChildren()
Return a mutable
List representing the child UIComponent s
associated with this component. |
Map<String,List<javax.faces.component.behavior.ClientBehavior>> |
getClientBehaviors()
Returns a non-null, unmodifiable
|
String |
getClientId(javax.faces.context.FacesContext context)
Return a client-side identifier for this component, generating
one if necessary.
|
String |
getDefaultEventName()
Returns the default event
name for this |
Collection<String> |
getEventNames()
Returns a non-null, unmodifiable
|
protected javax.faces.context.FacesContext |
getFacesContext()
Convenience method to return the
FacesContext instance
for the current request. |
protected javax.faces.event.FacesListener[] |
getFacesListeners(Class clazz)
Return an array of registered
FacesListener s that are
instances of the specified class. |
javax.faces.component.UIComponent |
getFacet(String name)
Convenience method to return the named facet, if it exists, or
null otherwise. |
Map<String,javax.faces.component.UIComponent> |
getFacets()
Return a mutable
Map representing the facet
UIComponent s associated with this UIComponent ,
keyed by facet name (which must be a String). |
Iterator<javax.faces.component.UIComponent> |
getFacetsAndChildren()
Return an
Iterator over the facet followed by child
UIComponent s of this UIComponent . |
String |
getFamily()
Return the identifier of the component family to which this component belongs. |
String |
getId()
Return the component identifier of this
UIComponent . |
javax.faces.component.UIComponent |
getParent()
Return the parent
UIComponent of this
UIComponent , if any. |
Map<String,Object> |
getPassThroughAttributes(boolean create)
This method has the same specification as
|
protected javax.faces.render.Renderer |
getRenderer(javax.faces.context.FacesContext context)
Convenience method to return the
Renderer instance
associated with this component, if any; otherwise, return
null . |
String |
getRendererType()
Return the
Renderer type for this UIComponent
(if any). |
boolean |
getRendersChildren()
Return a flag indicating whether this component is responsible
for rendering its child components.
|
javax.faces.el.ValueBinding |
getValueBinding(String name)
Deprecated.
|
javax.el.ValueExpression |
getValueExpression(String name)
Return the
ValueExpression used to calculate the value for the
specified attribute or property name, if any. |
boolean |
invokeOnComponent(javax.faces.context.FacesContext context,
String clientId,
javax.faces.component.ContextCallback callback)
Starting at this
component in the View hierarchy, search for a component with a
clientId equal to the argument clientId
and, if found, call the ContextCallback.invokeContextCallback(javax.faces.context.FacesContext, javax.faces.component.UIComponent) method on the argument
callback , passing the current FacesContext
and the found component as arguments. |
boolean |
isInView()
Return |
boolean |
isRendered()
Return
true if this component (and its children)
should be rendered during the Render Response phase
of the request processing lifecycle. |
boolean |
isTransient()
If true, the Object implementing this interface must not
participate in state saving or restoring.
|
void |
processDecodes(javax.faces.context.FacesContext context)
Perform the
component tree processing required by the Apply Request
Values phase of the request processing lifecycle for all
facets of this component, all children of this component, and
this component itself, as follows.
|
void |
processEvent(javax.faces.event.ComponentSystemEvent event)
The default implementation performs the following action. |
void |
processRestoreState(javax.faces.context.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.
|
Object |
processSaveState(javax.faces.context.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.
|
void |
processUpdates(javax.faces.context.FacesContext context)
Perform the
component tree processing required by the Update Model
Values phase of the request processing lifecycle for all
facets of this component, all children of this component, and
this component itself, as follows.
|
void |
processValidators(javax.faces.context.FacesContext context)
Perform the component
tree processing required by the Process Validations
phase of the request processing lifecycle for all facets of this
component, all children of this component, and this component
itself, as follows.
|
void |
queueEvent(javax.faces.event.FacesEvent event)
Queue an event for broadcast at the end of the current request
processing lifecycle phase.
|
protected void |
removeFacesListener(javax.faces.event.FacesListener listener)
Remove the specified
FacesListener from the set of listeners
registered to receive event notifications from this UIComponent . |
void |
restoreState(javax.faces.context.FacesContext context,
Object state)
Perform any
processing required to restore the state from the entries in the
state Object.
|
Object |
saveState(javax.faces.context.FacesContext context)
Gets the state of the instance as a
Serializable Object. |
void |
setId(String id)
Set the component identifier of this
UIComponent (if any). |
void |
setParent(javax.faces.component.UIComponent parent)
Set the parent
|
void |
setRendered(boolean rendered)
Set the
rendered property of this
UIComponent . |
void |
setRendererType(String rendererType)
Set the
Renderer type for this UIComponent ,
or null for components that render themselves. |
void |
setTransient(boolean newTransientValue)
Denotes
whether or not the Object implementing this interface must or
must not participate in state saving or restoring.
|
void |
setValueBinding(String name,
javax.faces.el.ValueBinding binding)
Deprecated.
|
void |
setValueExpression(String name,
javax.el.ValueExpression binding)
Set the
ValueExpression used to calculate the value
for the specified attribute or property name, if any. |
void |
subscribeToEvent(Class<? extends javax.faces.event.SystemEvent> eventClass,
javax.faces.event.ComponentSystemEventListener componentListener)
This implementation throws
|
void |
unsubscribeFromEvent(Class<? extends javax.faces.event.SystemEvent> eventClass,
javax.faces.event.ComponentSystemEventListener componentListener)
This implementation throws
|
boolean |
visitTree(javax.faces.component.visit.VisitContext context,
javax.faces.component.visit.VisitCallback callback)
Perform a tree visit starting at this node in the tree. |
clearInitialState, encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getFacetCount, getListenersForEventClass, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, initialStateMarked, isCompositeComponent, isVisitable, markInitialState, popComponentFromEL, pushComponentToEL, restoreTransientState, saveTransientState, setInView
public void broadcast(javax.faces.event.FacesEvent event) throws javax.faces.event.AbortProcessingException
javax.faces.component.UIComponent
Broadcast the specified FacesEvent
to 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 event
is an instance of
BehaviorEvent
and the current
component
is the source of the event
call BehaviorEvent.getBehavior()
to get the
Behavior
for the event.
Call Behavior.broadcast(javax.faces.event.BehaviorEvent)
on the Behavior
instance.
broadcast
in class javax.faces.component.UIComponent
event
- The FacesEvent
to be broadcastjavax.faces.event.AbortProcessingException
- Signal the JavaServer Faces
implementation that no further processing on the current event
should be performedUIComponent.broadcast(javax.faces.event.FacesEvent)
public void decode(javax.faces.context.FacesContext context)
javax.faces.component.UIComponent
Decode any new state of this UIComponent
from the
request contained in the specified FacesContext
, 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()
.
decode
in class javax.faces.component.UIComponent
context
- FacesContext
for the request we are processingUIComponent.decode(javax.faces.context.FacesContext)
public void encodeBegin(javax.faces.context.FacesContext context) throws IOException
javax.faces.component.UIComponent
If our
rendered
property is true
, render the
beginning of the current state of this UIComponent
to the
response contained in the specified FacesContext
.
Call UIComponent.pushComponentToEL(javax.faces.context.FacesContext,javax.faces.component.UIComponent)
.
Call Application.publishEvent(javax.faces.context.FacesContext, java.lang.Class<? extends javax.faces.event.SystemEvent>, java.lang.Object)
, passing
PreRenderComponentEvent
.class
as the
first argument and the component instance to be rendered as the
second argument.
If a Renderer
is associated with this UIComponent
, the actual encoding will be delegated to
Renderer.encodeBegin(FacesContext, UIComponent)
.
If our rendered
property is
false
, call UIComponent.pushComponentToEL(javax.faces.context.FacesContext,javax.faces.component.UIComponent)
and return immediately.
encodeBegin
in class javax.faces.component.UIComponent
context
- FacesContext
for the response we are creatingIOException
- if an input/output error occurs while renderingUIComponent.encodeBegin(javax.faces.context.FacesContext)
public void encodeChildren(javax.faces.context.FacesContext context) throws IOException
javax.faces.component.UIComponent
If our rendered
property is true
,
render the child UIComponent
s of this UIComponent
.
This method will only be called
if the rendersChildren
property is true
.
If a Renderer
is associated with this UIComponent
,
the actual encoding will be delegated to
Renderer.encodeChildren(FacesContext, UIComponent)
.
If no Renderer
is associated
with this UIComponent
, iterate over each of the children of this
component and call
UIComponent.encodeAll(javax.faces.context.FacesContext)
.
encodeChildren
in class javax.faces.component.UIComponent
context
- FacesContext
for the response we are creatingIOException
- if an input/output error occurs while renderingUIComponent.encodeChildren(javax.faces.context.FacesContext)
public void encodeEnd(javax.faces.context.FacesContext context) throws IOException
javax.faces.component.UIComponent
If our
rendered
property is true
, render the
ending of the current state of this UIComponent
.
If a Renderer
is associated with this UIComponent
,
the actual encoding will be delegated to
Renderer.encodeEnd(FacesContext, UIComponent)
.
Call UIComponent.popComponentFromEL(javax.faces.context.FacesContext)
. before returning regardless of the value
of the rendered
property.
encodeEnd
in class javax.faces.component.UIComponent
context
- FacesContext
for the response we are creatingIOException
- if an input/output error occurs while renderingUIComponent.encodeEnd(javax.faces.context.FacesContext)
public javax.faces.component.UIComponent findComponent(String expr)
javax.faces.component.UIComponent
Search for and
return the UIComponent
with an id
that
matches the specified search expression (if any), according to
the algorithm described below.
WARNING: The found
UIComponent
instance, if any, is returned
without regard for its tree traversal context.
Retrieving an EL-bound attribute from the component is not safe.
EL 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. See UIComponent.invokeOnComponent(javax.faces.context.FacesContext, java.lang.String, javax.faces.component.ContextCallback)
for a method that does
correctly account for the tree traversal context when operating
on the found UIComponent
instance. UIComponent.invokeOnComponent(javax.faces.context.FacesContext, java.lang.String, javax.faces.component.ContextCallback)
is also useful to find components given a simple clientId
.
Component identifiers are required to be unique within the scope of
the closest ancestor NamingContainer
that encloses this
component (which might be this component itself). If there are no
NamingContainer
components in the ancestry of this component,
the root component in the tree is treated as if it were a
NamingContainer
, whether or not its class actually implements
the NamingContainer
interface.
A search expression consists of either an identifier
(which is matched exactly against the id
property of
a UIComponent
, or a series of such identifiers linked by
the UINamingContainer.getSeparatorChar(javax.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:
UIComponent
that will be the base for searching,
by stopping as soon as one of the following conditions is met:
UIComponent
of 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.UIComponent
is a
NamingContainer
it will serve as the basis.NamingContainer
is encountered, it will be the base.
NamingContainer
is encountered)
the root UIComponent
will be the base.id
that matches, within
the scope of the base component. The match is performed as follows:
id
property, and then recursively
through the facets and children of the base UIComponent
(except that if a descendant NamingContainer
is found,
its own facets and children are not searched).NamingContainer
by the rules in the
previous bullet point. Then, the findComponent()
method of this NamingContainer
will be called, passing
the remainder of the search expression.findComponent
in class javax.faces.component.UIComponent
expr
- Search expression identifying the UIComponent
to be returnedUIComponent
, or null
if the component was not found.UIComponent.findComponent(java.lang.String)
public Map<String,Object> getAttributes()
javax.faces.component.UIComponent
Return a mutable
Map
representing the attributes
(and properties, see below) associated wth this UIComponent
,
keyed by attribute name (which must be a String). The returned
implementation must support all of the standard and optional
Map
methods, plus support the following additional
requirements:
Map
implementation must implement
the java.io.Serializable
interface.null
key or value must
throw a NullPointerException
.ClassCastException
.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
.getAttributes
in class javax.faces.component.UIComponent
UIComponent.getAttributes()
public Map<String,Object> getPassThroughAttributes(boolean create)
javax.faces.component.UIComponent
This method has the same specification as
UIComponent.getPassThroughAttributes()
except that it is allowed to return
null
if and only if the argument create
is false
and no pass through attribute data structure exists for this instance.
The returned Map
implementation must support all of the standard and optional
Map
methods, plus support the following additional requirements.
The map must be stored in using UIComponent.getStateHelper()
.
The Map
implementation must implement java.io.Serializable
.
Any attempt to add a null
key or value must throw a NullPointerException
.
Any attempt to add a key that is not a String
must
throw an IllegalArgumentException
.
For backward compatibility with components that extend directly from this class, a default implementation is provided that returns the empty map.
getPassThroughAttributes
in class javax.faces.component.UIComponent
create
- if true
, a new Map
instance will be created if it does not exist already. If
false
, and there is no existing
Map
instance, one will not be created and
null
will be returned.Map
instance, or null
.public int getChildCount()
javax.faces.component.UIComponent
Return the number of child UIComponent
s that are
associated with this UIComponent
. If there are no
children, this method must return 0. The method must not cause
the creation of a child component list.
getChildCount
in class javax.faces.component.UIComponent
UIComponent.getChildCount()
public List<javax.faces.component.UIComponent> getChildren()
javax.faces.component.UIComponent
Return a mutable
List
representing the child UIComponent
s
associated with this component. The returned implementation must
support all of the standard and optional List
methods, plus support the following additional requirements:
List
implementation must implement the
java.io.Serializable
interface.null
must throw a NullPointerExceptionUIComponent
must throw a ClassCastException.parent
property of
the child must be set to this component instance. If the
parent
property 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).parent
property of the child must be set to null
.After the child component has
been added to the view, Application.publishEvent(javax.faces.context.FacesContext, java.lang.Class<? extends javax.faces.event.SystemEvent>, java.lang.Object)
must be
called, passing PostAddToViewEvent
.class
as
the first argument and the newly added component as the
second argument if any the following cases are true.
FacesContext.getCurrentPhaseId()
returns
PhaseId.RESTORE_VIEW
and partial
state saving is enabled.
FacesContext.isPostback()
returns false
and FacesContext.getCurrentPhaseId()
returns
something other than PhaseId.RESTORE_VIEW
getChildren
in class javax.faces.component.UIComponent
UIComponent.getChildren()
public String getClientId(javax.faces.context.FacesContext context)
javax.faces.component.UIComponent
Return 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 id
property
of the component is changed, or the component is placed in
a NamingContainer
whose 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
. Call
getContainerClientId()
on it and save the result as
the parentId
local variable. Call UIComponent.getId()
on
this component and save the result as the
myId
local variable. If myId
is
null
, call
context.getViewRoot().createUniqueId()
and assign
the result to myId. If parentId
is
non-null
, let myId
equal parentId
+
. Call
UINamingContainer.getSeparatorChar(javax.faces.context.FacesContext)
+ myIdRenderer.convertClientId(javax.faces.context.FacesContext, java.lang.String)
, passing myId
, and
return the result.
getClientId
in class javax.faces.component.UIComponent
context
- The FacesContext
for the current requestUIComponent.getClientId(javax.faces.context.FacesContext)
public javax.faces.component.UIComponent getFacet(String name)
javax.faces.component.UIComponent
Convenience method to return the named facet, if it exists, or
null
otherwise. If the requested facet does not
exist, the facets Map must not be created.
getFacet
in class javax.faces.component.UIComponent
name
- Name of the desired facetnull
.UIComponent.getFacet(java.lang.String)
public Map<String,javax.faces.component.UIComponent> getFacets()
javax.faces.component.UIComponent
Return a mutable Map
representing the facet
UIComponent
s associated with this UIComponent
,
keyed by facet name (which must be a String). The returned
implementation must support all of the standard and optional
Map
methods, plus support the following additional
requirements:
Map
implementation must implement
the java.io.Serializable
interface.null
key or value must
throw a NullPointerException.UIComponent
must throw a ClassCastException.UIComponent
is added:
parent
property of the component must be set to
this component instance.parent
property 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).UIComponent
is removed:
parent
property of the facet must be
set to null
.getFacets
in class javax.faces.component.UIComponent
UIComponent.getFacets()
public Iterator<javax.faces.component.UIComponent> getFacetsAndChildren()
javax.faces.component.UIComponent
Return an Iterator
over the facet followed by child
UIComponent
s of this UIComponent
.
Facets are returned in an undefined order, followed by
all the children in the order they are stored in the child list. If this
component has no facets or children, an empty Iterator
is returned.
The returned Iterator
must not support the
remove()
operation.
getFacetsAndChildren
in class javax.faces.component.UIComponent
UIComponent.getFacetsAndChildren()
public String getFamily()
javax.faces.component.UIComponent
Return the identifier of the component
family to which this component belongs. This identifier, in conjunction
with the value of the rendererType
property, may be used to
select the appropriate Renderer
for this component instance.
Note this method should NOT return null
getFamily
in class javax.faces.component.UIComponent
UIComponent.getFamily()
public String getId()
javax.faces.component.UIComponent
Return the component identifier of this UIComponent
.
getId
in class javax.faces.component.UIComponent
UIComponent.getId()
public javax.faces.component.UIComponent getParent()
javax.faces.component.UIComponent
Return the parent UIComponent
of this
UIComponent
, 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
from getParent( )
.
getParent
in class javax.faces.component.UIComponent
UIComponent.getParent()
public String getRendererType()
javax.faces.component.UIComponent
Return the Renderer
type for this UIComponent
(if any).
getRendererType
in class javax.faces.component.UIComponent
UIComponent.getRendererType()
public boolean getRendersChildren()
javax.faces.component.UIComponent
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 calls Renderer.getRendersChildren()
and returns the result. If it
doesn't, it returns false. As of version 1.2 of the JavaServer
Faces Specification, component authors are encouraged to return
true
from this method and rely on UIComponentBase.encodeChildren(javax.faces.context.FacesContext)
.
getRendersChildren
in class javax.faces.component.UIComponent
true
if the component renders its children, false
otherwise.UIComponent.getRendersChildren()
public javax.faces.el.ValueBinding getValueBinding(String name)
javax.faces.component.UIComponent
Call through to UIComponent.getValueExpression(java.lang.String)
and examine the
result. If the result is an instance of the wrapper class
mandated in UIComponent.setValueBinding(java.lang.String, javax.faces.el.ValueBinding)
, extract the
ValueBinding
instance and return it. Otherwise,
wrap the result in an implementation of
ValueBinding
, and return it.
getValueBinding
in class javax.faces.component.UIComponent
name
- Name of the attribute or property for which to retrieve a
ValueBinding
UIComponent.getValueBinding(java.lang.String)
public javax.el.ValueExpression getValueExpression(String name)
javax.faces.component.UIComponent
Return the ValueExpression
used 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 JSF 1.2 and later.
getValueExpression
in class javax.faces.component.UIComponent
name
- Name of the attribute or property for which to retrieve a
ValueExpression
null
.UIComponent.getValueExpression(java.lang.String)
public boolean invokeOnComponent(javax.faces.context.FacesContext context, String clientId, javax.faces.component.ContextCallback callback) throws javax.faces.FacesException
javax.faces.component.UIComponent
Starting at this
component in the View hierarchy, search for a component with a
clientId
equal to the argument clientId
and, if found, call the ContextCallback.invokeContextCallback(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
method on the argument
callback
, passing the current FacesContext
and the found component as arguments. This method is similar to
UIComponent.findComponent(java.lang.String)
but it does not support the leading UINamingContainer.getSeparatorChar(javax.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 argument
clientId
. If so, first call UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
,
then call the ContextCallback.invokeContextCallback(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
method on the argument
callback, passing through the FacesContext
argument
and passing this as the component argument. Then call UIComponent.popComponentFromEL(javax.faces.context.FacesContext)
.
If an Exception
is thrown by the callback, wrap it
in a FacesException
and re-throw it. Otherwise, return
true
.
Otherwise, for each component returned by UIComponent.getFacetsAndChildren()
, call invokeOnComponent()
passing the arguments to this method, in order. The first time
invokeOnComponent()
returns true, abort traversing
the rest of the Iterator
and return
true
.
When calling ContextCallback.invokeContextCallback(javax.faces.context.FacesContext, javax.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 argument clientId
. For example,
an iterating component such as UIData
will need to set
its row index to correctly reflect the argument
clientId
before finding the appropriate child
component backed by the correct row. When the callback returns,
either normally or by throwing an Exception
the
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 UIComponent.getFacetsAndChildren()
returned true
from
invokeOnComponent()
, return false
.
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;
}
});
}
invokeOnComponent
in class javax.faces.component.UIComponent
context
- the FacesContext
for the current requestclientId
- the client identifier of the component to be passed
to the argument callback.callback
- an implementation of the Callback interface.true
if the a component with the given
clientId
is found, the callback method was
successfully invoked passing that component as an argument, and
no Exception was thrown. Returns false
if no
component with the given clientId
is found.javax.faces.FacesException
- if the argument Callback throws an
Exception, it is wrapped in a FacesException
and re-thrown.UIComponent.invokeOnComponent(javax.faces.context.FacesContext, java.lang.String, javax.faces.component.ContextCallback)
public boolean isInView()
javax.faces.component.UIComponent
Return true
if this
component is within the view hierarchy otherwise
false
isInView
in class javax.faces.component.UIComponent
true
if within a view hierarchy, false
otherwise.UIComponent.isInView()
public boolean isRendered()
javax.faces.component.UIComponent
Return true
if this component (and its children)
should be rendered during the Render Response phase
of the request processing lifecycle.
isRendered
in class javax.faces.component.UIComponent
true
if the component should be rendered, false
otherwise.UIComponent.isRendered()
public boolean isTransient()
javax.faces.component.StateHolder
If true, the Object implementing this interface must not participate in state saving or restoring.
isTransient
in interface javax.faces.component.StateHolder
true
if transient, false
otherwise.StateHolder.isTransient()
public void processDecodes(javax.faces.context.FacesContext context)
javax.faces.component.UIComponent
Perform the component tree processing required by the Apply Request Values phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
rendered
property of this UIComponent
is false
, skip further processing.UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
.processDecodes()
method of all facets
and children of this UIComponent
, in the order determined
by a call to getFacetsAndChildren()
.decode()
method of this component.UIComponent.popComponentFromEL(javax.faces.context.FacesContext)
from inside of a
finally block, just before returning.
RuntimeException
is thrown during
decode processing, call FacesContext.renderResponse()
and re-throw the exception.processDecodes
in class javax.faces.component.UIComponent
context
- FacesContext
for the request we are processingUIComponent.processDecodes(javax.faces.context.FacesContext)
public void processEvent(javax.faces.event.ComponentSystemEvent event) throws javax.faces.event.AbortProcessingException
javax.faces.component.UIComponent
The default implementation performs
the following action. If the argument event
is an
instance of PostRestoreStateEvent
, call
this.
UIComponent.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 the ValueExpression
to be this
.
processEvent
in interface javax.faces.event.ComponentSystemEventListener
processEvent
in class javax.faces.component.UIComponent
event
- the ComponentSystemEvent
instance that
is being processed.javax.faces.event.AbortProcessingException
- if lifecycle processing should
cease for this request.UIComponent.processEvent(javax.faces.event.ComponentSystemEvent)
public void processRestoreState(javax.faces.context.FacesContext context, Object state)
javax.faces.component.UIComponent
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.
restoreState()
method of this component.UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
. processRestoreState()
method of all
facets and children of this UIComponent
in the order
determined by a call to getFacetsAndChildren()
.
After returning from the
processRestoreState()
method on a child or facet,
call UIComponent.popComponentFromEL(javax.faces.context.FacesContext)
This method may not be called if the state saving method is set to server.
processRestoreState
in class javax.faces.component.UIComponent
context
- FacesContext
for the request we are processingstate
- the state.UIComponent.processRestoreState(javax.faces.context.FacesContext, java.lang.Object)
public Object processSaveState(javax.faces.context.FacesContext context)
javax.faces.component.UIComponent
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.
transient
property of this
component. If true, just return null
.UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
.processSaveState()
method of all facets
and children of this UIComponent
in the order determined
by a call to getFacetsAndChildren()
, skipping
children and facets that are transient. Ensure that UIComponent.popComponentFromEL(javax.faces.context.FacesContext)
is called correctly after each child or
facet.saveState()
method of this component.This method may not be called if the state saving method is set to server.
processSaveState
in class javax.faces.component.UIComponent
context
- FacesContext
for the request we are processingUIComponent.processSaveState(javax.faces.context.FacesContext)
public void processUpdates(javax.faces.context.FacesContext context)
javax.faces.component.UIComponent
Perform the component tree processing required by the Update Model Values phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
rendered
property of this UIComponent
is false
, skip further processing.UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
.processUpdates()
method of all facets
and children of this UIComponent
, in the order determined
by a call to getFacetsAndChildren()
. After returning from the
processUpdates()
method on a child or facet, call
UIComponent.popComponentFromEL(javax.faces.context.FacesContext)
processUpdates
in class javax.faces.component.UIComponent
context
- FacesContext
for the request we are processingUIComponent.processUpdates(javax.faces.context.FacesContext)
public void processValidators(javax.faces.context.FacesContext context)
javax.faces.component.UIComponent
Perform the component tree processing required by the Process Validations phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
rendered
property of this UIComponent
is false
, skip further processing.UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
.processValidators()
method of all facets
and children of this UIComponent
, in the order determined
by a call to getFacetsAndChildren()
.getFacetsAndChildren()
call UIComponent.popComponentFromEL(javax.faces.context.FacesContext)
.processValidators
in class javax.faces.component.UIComponent
context
- FacesContext
for the request we are processingUIComponent.processValidators(javax.faces.context.FacesContext)
public void queueEvent(javax.faces.event.FacesEvent event)
javax.faces.component.UIComponent
Queue an event for broadcast at the end of the current request
processing lifecycle phase. The default implementation in
UIComponentBase
must delegate this call to the
queueEvent()
method of the parent UIComponent
.
queueEvent
in class javax.faces.component.UIComponent
event
- FacesEvent
to be queuedUIComponent.queueEvent(javax.faces.event.FacesEvent)
public void restoreState(javax.faces.context.FacesContext context, Object state)
javax.faces.component.StateHolder
Perform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to
instances that also implement StateHolder (such as a
UIComponent
with event handlers, validators, etc.)
this method must call the StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
method on all those
instances as well.
If the state
argument is null
, take no action and return.
restoreState
in interface javax.faces.component.StateHolder
context
- the Faces context.state
- the state.StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
public Object saveState(javax.faces.context.FacesContext context)
javax.faces.component.StateHolder
Gets the state of the instance as a
Serializable
Object.
If the class that implements this interface has references to
instances that implement StateHolder (such as a
UIComponent
with event handlers, validators, etc.)
this method must call the StateHolder.saveState(javax.faces.context.FacesContext)
method on all those
instances as well. This method must not save the state
of children and facets. That is done via the StateManager
This method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);
component
should be the same as before executing
it.
The return from this method must be Serializable
saveState
in interface javax.faces.component.StateHolder
context
- the Faces context.StateHolder.saveState(javax.faces.context.FacesContext)
public void setId(String id)
javax.faces.component.UIComponent
Set the component identifier of this UIComponent
(if any).
Component identifiers must obey the following syntax restrictions:
Component identifiers must also obey the following semantic
restrictions (note that this restriction is NOT
enforced by the setId()
implementation):
UIComponent
that is a NamingContainer
, or within
the scope of the entire component tree if there is no such
ancestor that is a NamingContainer
.setId
in class javax.faces.component.UIComponent
id
- The new component identifier, or null
to indicate
that this UIComponent
does not have a component identifierUIComponent.setId(java.lang.String)
public void setParent(javax.faces.component.UIComponent parent)
javax.faces.component.UIComponent
Set the parent
UIComponent
of this UIComponent
. If
parent.isInView()
returns true
, calling
this method will first cause a PreRemoveFromViewEvent
to be published, for
this node, and then the children of this node. Then, once the
re-parenting has occurred, a PostAddToViewEvent
will 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()
returns
PhaseId.RESTORE_VIEW
and partial
state saving is enabled.
FacesContext.isPostback()
returns false
and FacesContext.getCurrentPhaseId()
returns
something other than PhaseId.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 child List
or facet
Map
.
setParent
in class javax.faces.component.UIComponent
parent
- The new parent, or null
for the root node
of a component treeUIComponent.setParent(javax.faces.component.UIComponent)
public void setRendered(boolean rendered)
javax.faces.component.UIComponent
Set the rendered
property of this
UIComponent
.
setRendered
in class javax.faces.component.UIComponent
rendered
- If true
render this component;
otherwise, do not render this componentUIComponent.setRendered(boolean)
public void setRendererType(String rendererType)
javax.faces.component.UIComponent
Set the Renderer
type for this UIComponent
,
or null
for components that render themselves.
setRendererType
in class javax.faces.component.UIComponent
rendererType
- Logical identifier of the type of
Renderer
to use, or null
for components
that render themselvesUIComponent.setRendererType(java.lang.String)
public void setTransient(boolean newTransientValue)
javax.faces.component.StateHolder
Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
setTransient
in interface javax.faces.component.StateHolder
newTransientValue
- boolean pass true
if this
Object will not
participate in state saving or restoring, otherwise pass
false
.StateHolder.setTransient(boolean)
public void setValueBinding(String name, javax.faces.el.ValueBinding binding)
javax.faces.component.UIComponent
Wrap the argument binding
in an implementation of
ValueExpression
and call through to UIComponent.setValueExpression(java.lang.String, javax.el.ValueExpression)
.
setValueBinding
in class javax.faces.component.UIComponent
name
- Name of the attribute or property for which to set a
ValueBinding
binding
- The ValueBinding
to set, or null
to remove any currently set ValueBinding
UIComponent.setValueBinding(java.lang.String, javax.faces.el.ValueBinding)
public void setValueExpression(String name, javax.el.ValueExpression binding)
javax.faces.component.UIComponent
Set the ValueExpression
used to calculate the value
for the specified attribute or property name, if any.
The implementation must call Expression.isLiteralText()
on the argument
expression
. If isLiteralText()
returns
true
, invoke ValueExpression.getValue(javax.el.ELContext)
on the
argument expression and pass the result as the value
parameter in a call to this.
where UIComponent.getAttributes()
.put(name, value)name
is the argument name
. If an exception is thrown as
a result of calling ValueExpression.getValue(javax.el.ELContext)
, wrap it in
a FacesException
and re-throw it. If
isLiteralText()
returns false
, simply
store the un-evaluated expression
argument in the
collection of ValueExpression
s under the key given
by the argument name
.
This method must be overridden and implemented for components that comply with JSF 1.2 and later.
setValueExpression
in class javax.faces.component.UIComponent
name
- Name of the attribute or property for which to set a
ValueExpression
binding
- The ValueExpression
to set, or null
to remove any currently set ValueExpression
UIComponent.setValueExpression(java.lang.String, javax.el.ValueExpression)
public void subscribeToEvent(Class<? extends javax.faces.event.SystemEvent> eventClass, javax.faces.event.ComponentSystemEventListener componentListener)
javax.faces.component.UIComponent
This implementation throws
UnsupportedOperationException
and is provided
for the sole purpose of not breaking existing applications that extend
this class. UIComponentBase
provides the implementation of
this method.
subscribeToEvent
in class javax.faces.component.UIComponent
eventClass
- the event class.componentListener
- the listener.UIComponent.subscribeToEvent(java.lang.Class, javax.faces.event.ComponentSystemEventListener)
public void unsubscribeFromEvent(Class<? extends javax.faces.event.SystemEvent> eventClass, javax.faces.event.ComponentSystemEventListener componentListener)
javax.faces.component.UIComponent
This implementation throws
UnsupportedOperationException
and is provided
for the sole purpose of not breaking existing applications that extend
this class. UIComponentBase
provides the implementation of
this method.
unsubscribeFromEvent
in class javax.faces.component.UIComponent
eventClass
- the event class.componentListener
- the component listener.UIComponent.unsubscribeFromEvent(java.lang.Class, javax.faces.event.ComponentSystemEventListener)
public boolean visitTree(javax.faces.component.visit.VisitContext context, javax.faces.component.visit.VisitCallback callback)
javax.faces.component.UIComponent
Perform a tree visit starting at this node in the tree.
UIComponent.visitTree() implementations do not invoke the
VisitCallback
directly, but instead call VisitContext.invokeVisitCallback(javax.faces.component.UIComponent, javax.faces.component.visit.VisitCallback)
to invoke the callback. This
allows VisitContext
implementations to provide optimized
tree traversals, for example by only calling the VisitCallback
for a subset of components.
UIComponent.visitTree() implementations must call UIComponent.pushComponentToEL() before performing the visit and UIComponent.popComponentFromEL() after the visit.
visitTree
in class javax.faces.component.UIComponent
context
- the VisitContext
for this visitcallback
- the VisitCallback
instance
whose visit
method will be called
for each node visited.true
to indicate that the tree visit is complete (eg. all components
that need to be visited have been visited). This results in
the tree visit being short-circuited such that no more components
are visited.
UIComponent.visitTree(javax.faces.component.visit.VisitContext, javax.faces.component.visit.VisitCallback)
protected void addFacesListener(javax.faces.event.FacesListener listener)
javax.faces.component.UIComponent
Add the specified FacesListener
to the set of listeners
registered to receive event notifications from this UIComponent
.
It is expected that UIComponent
classes 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); } ... }
addFacesListener
in class javax.faces.component.UIComponent
listener
- The FacesListener
to be registeredprotected javax.faces.context.FacesContext getFacesContext()
javax.faces.component.UIComponent
Convenience method to return the FacesContext
instance
for the current request.
getFacesContext
in class javax.faces.component.UIComponent
protected javax.faces.event.FacesListener[] getFacesListeners(Class clazz)
javax.faces.component.UIComponent
Return an array of registered FacesListener
s 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 of clazz
.
getFacesListeners
in class javax.faces.component.UIComponent
clazz
- Class that must be implemented by a FacesListener
for it to be returnedprotected javax.faces.render.Renderer getRenderer(javax.faces.context.FacesContext context)
javax.faces.component.UIComponent
Convenience method to return the Renderer
instance
associated with this component, if any; otherwise, return
null
.
getRenderer
in class javax.faces.component.UIComponent
context
- FacesContext
for the current requestnull
.protected void removeFacesListener(javax.faces.event.FacesListener listener)
javax.faces.component.UIComponent
Remove the specified FacesListener
from the set of listeners
registered to receive event notifications from this UIComponent
.
removeFacesListener
in class javax.faces.component.UIComponent
listener
- The FacesListener
to be deregisteredpublic void addClientBehavior(String eventName, javax.faces.component.behavior.ClientBehavior behavior)
javax.faces.component.behavior.ClientBehaviorHolder
Attaches a ClientBehavior
to
the component implementing this interface for the specified event.
Valid event names for a UIComponent implementation are defined by
ClientBehaviorHolder.getEventNames()
.
addClientBehavior
in interface javax.faces.component.behavior.ClientBehaviorHolder
eventName
- the logical name of the client-side event to
attach the behavior to.behavior
- the ClientBehavior
instance to attach
for the specified event name.public Map<String,List<javax.faces.component.behavior.ClientBehavior>> getClientBehaviors()
javax.faces.component.behavior.ClientBehaviorHolder
Returns a non-null, unmodifiable
Map
that contains the the ClientBehavior
s that
have been attached to the component implementing this interface.
The keys in this Map
are event names defined by
ClientBehaviorHolder.getEventNames()
.
getClientBehaviors
in interface javax.faces.component.behavior.ClientBehaviorHolder
public String getDefaultEventName()
javax.faces.component.behavior.ClientBehaviorHolder
Returns the default event
name for this ClientBehaviorHolder
implementation.
This must be one of the event names returned by
ClientBehaviorHolder.getEventNames()
or null if the component does not have
a default event.
getDefaultEventName
in interface javax.faces.component.behavior.ClientBehaviorHolder
public Collection<String> getEventNames()
javax.faces.component.behavior.ClientBehaviorHolder
Returns a non-null, unmodifiable
Collection
containing the names of the logical
events supported by the component implementing this interface.
getEventNames
in interface javax.faces.component.behavior.ClientBehaviorHolder
Copyright © 2010–2019 JBoss by Red Hat. All rights reserved.