Method from javax.faces.component.UIComponent Detail: |
abstract protected void addFacesListener(FacesListener listener)
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);
}
...
}
|
abstract public void broadcast(FacesEvent event) throws AbortProcessingException
|
public void clearInitialState() {
initialState = false;
}
|
abstract public void decode(FacesContext context)
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() .
|
public void encodeAll(FacesContext context) throws IOException {
if (context == null) {
throw new NullPointerException();
}
if (!isRendered()) {
return;
}
encodeBegin(context);
if (getRendersChildren()) {
encodeChildren(context);
} else if (this.getChildCount() > 0) {
for (UIComponent kid : getChildren()) {
kid.encodeAll(context);
}
}
encodeEnd(context);
}
If this component
returns true from #isRendered , take the
following action.
Render this component and all its children that return
true from isRendered() , regardless of
the value of the #getRendersChildren flag.
|
abstract public void encodeBegin(FacesContext context) throws IOException
|
abstract public void encodeChildren(FacesContext context) throws IOException
|
abstract public void encodeEnd(FacesContext context) throws IOException
|
abstract public 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.
For a method to find a component given a simple
clientId , see #invokeOnComponent .
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 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 UIComponent that 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 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.
- Otherwise, if this UIComponent is a
NamingContainer it will serve as the basis.
- Otherwise, search up the parents of this component. If
a NamingContainer is encountered, it will be the base.
- Otherwise (if no NamingContainer is encountered)
the root UIComponent will be the base.
- 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
id that 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
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).
- If the search expression includes more than one identifier
separated by the separator character, the first identifier is
used to locate a 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.
|
abstract public 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). The returned
implementation must support all of the standard and optional
Map methods, plus support the following additional
requirements:
- The
Map implementation must implement
the java.io.Serializable interface.
- 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
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 .
|
abstract public int getChildCount()
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.
|
abstract public List<UIComponent> getChildren()
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:
- The
List implementation must implement the
java.io.Serializable interface. - Any attempt
to add a
null must throw a NullPointerException
- Any attempt to add an object that does not implement UIComponent must throw a ClassCastException.
- Whenever a
new child component is added, the
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). - Whenever an
existing child component is removed, the
parent
property of the child must be set to null .
After the child component has
been added to the view, if the following condition is
not met:
javax.faces.application.Application#publishEvent
must be called, passing javax.faces.event.PostAddToViewEvent .class
as the first argument and the newly added component as the
second argument.
|
public String getClientId() {
FacesContext context = FacesContext.getCurrentInstance();
return getClientId(context);
}
|
abstract public String getClientId(FacesContext context)
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 #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
+ UINamingContainer#getSeparatorChar + myId . Call
Renderer#convertClientId , passing myId , and
return the result.
|
public static UIComponent getCompositeComponentParent(UIComponent component) {
if (component == null) {
return null;
} else {
if (component.compositeParent != null) {
return component.compositeParent;
}
UIComponent parent = component.getParent();
while (parent != null) {
if (UIComponent.isCompositeComponent(parent)) {
if (component.isInView()) {
component.compositeParent = parent;
}
return parent;
}
parent = parent.getParent();
}
return null;
}
}
|
public String getContainerClientId(FacesContext context) {
if (context == null) {
throw new NullPointerException();
}
return this.getClientId(context);
}
Allow components that implement NamingContainer to
selectively disable prepending their clientId to their
descendent's clientIds by breaking the prepending logic into a
seperately callable method. See #getClientId for usage.
By default, this method will call through to #getClientId and return the result.
|
public static UIComponent getCurrentComponent(FacesContext context) {
if (context == null) {
throw new NullPointerException();
}
Map< Object, Object > contextMap = context.getAttributes();
return (UIComponent) contextMap.get(CURRENT_COMPONENT);
}
Return the UIComponent
instance that is currently processing. This is equivalent to
evaluating the EL expression "#{component} " and
doing a getValue operation on the resultant
ValueExpression .
This method must return
null if there is no currently processing
UIComponent
|
public static UIComponent getCurrentCompositeComponent(FacesContext context) {
if (context == null) {
throw new NullPointerException();
}
Map< Object, Object > contextMap = context.getAttributes();
return (UIComponent) contextMap.get(CURRENT_COMPOSITE_COMPONENT);
}
Return the closest ancestor
component, relative to the component returned from #getCurrentComponent , that is a composite component, or
null if no such component exists.
|
abstract protected FacesContext getFacesContext()
|
abstract protected FacesListener[] getFacesListeners(Class clazz)
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 .
|
abstract public UIComponent getFacet(String name)
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.
|
public int getFacetCount() {
return (getFacets().size());
}
Return the number of facet UIComponent s that are
associated with this UIComponent . 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 the size() method on the
returned Map . A more optimized version of this method is
provided in UIComponentBase#getFacetCount .
|
abstract public Map<String, UIComponent> getFacets()
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:
- The
Map implementation must implement
the java.io.Serializable interface.
- 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
a ClassCastException.
- Any attempt to add a value that is not a UIComponent
must throw a ClassCastException.
- Whenever a new facet UIComponent is added:
- The
parent property of the component must be set to
this component instance.
- If the
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).
- Whenever an existing facet UIComponent is removed:
- The
parent property of the facet must be
set to null .
|
abstract public Iterator<UIComponent> getFacetsAndChildren()
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.
|
abstract public String getFamily()
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.
|
abstract public String getId()
|
public List<SystemEventListener> getListenersForEventClass(Class<SystemEvent> eventClass) {
if (eventClass == null) {
throw new NullPointerException();
}
List< SystemEventListener > result = null;
if (listenersByEventClass != null) {
result = listenersByEventClass.get(eventClass);
}
return result;
}
Return the
SystemEventListener instances registered on this
UIComponent instance that are interested in events
of type eventClass .
|
public UIComponent getNamingContainer() {
UIComponent namingContainer = this;
while (namingContainer != null) {
if (namingContainer instanceof NamingContainer) {
return namingContainer;
}
namingContainer = namingContainer.getParent();
}
return null;
}
Starting with "this", return the closest
component in the ancestry that is a NamingContainer
or null if none can be found.
|
abstract public UIComponent getParent()
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( ) .
|
abstract protected Renderer getRenderer(FacesContext context)
Convenience method to return the Renderer instance
associated with this component, if any; otherwise, return
null .
|
abstract public String getRendererType()
|
abstract public 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 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 .
|
public Map<String, String> getResourceBundleMap() {
if (null == resourceBundleMap) {
// See if there is a ResourceBundle under the FQCN for this class
String className = this.getClass().getName();
Locale currentLocale = null;
FacesContext context = null;
UIViewRoot root = null;
ResourceBundle resourceBundle = null;
// Step 1: look for a ResourceBundle under the FQCN of this instance
if (null != (context = FacesContext.getCurrentInstance())) {
if (null != (root = context.getViewRoot())) {
currentLocale = root.getLocale();
}
}
if (null == currentLocale) {
currentLocale = Locale.getDefault();
}
try {
resourceBundle =
ResourceBundle.getBundle(className, currentLocale);
} catch (MissingResourceException e) {
// It is not an error if there is no ResourceBundle
}
// Step 2: if this is a composite component, look for a
// ResourceBundle as a Resource
if (null == resourceBundle) {
if (this.getAttributes().containsKey(Resource.COMPONENT_RESOURCE_KEY)) {
Resource ccResource = (Resource)
this.getAttributes().get(Resource.COMPONENT_RESOURCE_KEY);
if (null != ccResource) {
if (null != (ccResource =
findComponentResourceBundleLocaleMatch(context,
ccResource.getResourceName(),
ccResource.getLibraryName()))) {
try {
InputStream propertiesInputStream = ccResource.getInputStream();
resourceBundle = new PropertyResourceBundle(propertiesInputStream);
} catch (IOException ex) {
Logger.getLogger(UIComponent.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
// Step 3: if the previous steps yielded a ResourceBundle, wrap it
// with a Map
if (null != resourceBundle) {
final ResourceBundle bundle = resourceBundle;
resourceBundleMap =
new Map() {
// this is an immutable Map
public String toString() {
StringBuffer sb = new StringBuffer();
Iterator< Map.Entry< String, Object > > entries =
this.entrySet().iterator();
Map.Entry< String, Object > cur;
while (entries.hasNext()) {
cur = entries.next();
sb.append(cur.getKey()).append(": ").append(cur.getValue()).append('\n');
}
return sb.toString();
}
// Do not need to implement for immutable Map
public void clear() {
throw new UnsupportedOperationException();
}
public boolean containsKey(Object key) {
boolean result = false;
if (null != key) {
result = (null != bundle.getObject(key.toString()));
}
return result;
}
public boolean containsValue(Object value) {
Enumeration< String > keys = bundle.getKeys();
boolean result = false;
while (keys.hasMoreElements()) {
Object curObj = bundle.getObject(keys.nextElement());
if ((curObj == value) ||
((null != curObj) && curObj.equals(value))) {
result = true;
break;
}
}
return result;
}
public Set< Map.Entry< String, Object > > entrySet() {
HashMap< String, Object > mappings = new HashMap< String, Object >();
Enumeration< String > keys = bundle.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
Object value = bundle.getObject(key);
mappings.put(key, value);
}
return mappings.entrySet();
}
@Override
public boolean equals(Object obj) {
return !((obj == null) || !(obj instanceof Map))
&& entrySet().equals(((Map) obj).entrySet());
}
public Object get(Object key) {
if (null == key) {
return null;
}
try {
return bundle.getObject(key.toString());
} catch (MissingResourceException e) {
return "???" + key + "???";
}
}
public int hashCode() {
return bundle.hashCode();
}
public boolean isEmpty() {
Enumeration< String > keys = bundle.getKeys();
return !keys.hasMoreElements();
}
public Set keySet() {
Set< String > keySet = new HashSet< String >();
Enumeration< String > keys = bundle.getKeys();
while (keys.hasMoreElements()) {
keySet.add(keys.nextElement());
}
return keySet;
}
// Do not need to implement for immutable Map
public Object put(Object k, Object v) {
throw new UnsupportedOperationException();
}
// Do not need to implement for immutable Map
public void putAll(Map t) {
throw new UnsupportedOperationException();
}
// Do not need to implement for immutable Map
public Object remove(Object k) {
throw new UnsupportedOperationException();
}
public int size() {
int result = 0;
Enumeration< String > keys = bundle.getKeys();
while (keys.hasMoreElements()) {
keys.nextElement();
result++;
}
return result;
}
public java.util.Collection values() {
ArrayList< Object > result = new ArrayList< Object >();
Enumeration< String > keys = bundle.getKeys();
while (keys.hasMoreElements()) {
result.add(
bundle.getObject(keys.nextElement()));
}
return result;
}
};
}
if (null == resourceBundleMap) {
resourceBundleMap = Collections.EMPTY_MAP;
}
}
return resourceBundleMap;
}
Return a
Map<String,String> of the
ResourceBundle for this component. A component may
have a ResourceBundle associated with it. This
bundle may contain localized properties relating to instances of
this component. The default implementation first looks for a
ResourceBundle with a base name equal to the fully
qualified class name of the current UIComponent this
and Locale equal to the Locale of the
current UIViewRoot . If no such bundle is found, and
the component is a composite component, let resourceName
be the resourceName of the Resource for this
composite component, replacing the file extension with
".properties". Let libraryName be the
libraryName of the the Resource for this
composite component. Call javax.faces.application.ResourceHandler#createResource(java.lang.String,java.lang.String) ,
passing the derived resourceName and
libraryName. Note that this will automatically allow
for the localization of the ResourceBundle due to
the localization facility implemented in
createResource , which is specified in section
JSF.2.6.1.3 of the spec prose document. If the resultant Resource exists and can be found, the InputStream
for the resource is used to create a ResourceBundle .
If either of the two previous steps for obtaining the
ResourceBundle for this component is successful, the
ResourceBundle is wrapped in a
Map<String,String> and returned. Otherwise
Collections.EMPTY_MAP is returned.
|
protected StateHelper getStateHelper() {
return getStateHelper(true);
}
|
protected StateHelper getStateHelper(boolean create) {
if (create && stateHelper == null) {
stateHelper = new ComponentStateHelper(this);
}
return stateHelper;
}
Like #getStateHelper() , but
only create a state helper instance if the argument
creat is true .
|
abstract public ValueBinding getValueBinding(String name)Deprecated! This - has been replaced by #getValueExpression .
Call through to #getValueExpression and examine the
result. If the result is an instance of the wrapper class
mandated in #setValueBinding , extract the
ValueBinding instance and return it. Otherwise,
wrap the result in an implementation of
ValueBinding , and return it.
|
public ValueExpression getValueExpression(String name) {
if (name == null) {
throw new NullPointerException();
}
Map< String,ValueExpression > map = (Map< String,ValueExpression >)
getStateHelper().get(UIComponentBase.PropertyKeys.bindings);
return ((map != null) ? map.get(name) : null);
}
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.
|
public boolean initialStateMarked() {
return initialState;
}
|
public boolean invokeOnComponent(FacesContext context,
String clientId,
ContextCallback callback) throws FacesException {
if (null == context || null == clientId || null == callback) {
throw new NullPointerException();
}
boolean found = false;
if (clientId.equals(this.getClientId(context))) {
try {
callback.invokeContextCallback(context, this);
return true;
} catch (Exception e) {
throw new FacesException(e);
}
} else {
Iterator< UIComponent > itr = this.getFacetsAndChildren();
while (itr.hasNext() && !found) {
found = itr.next().invokeOnComponent(context, clientId,
callback);
}
}
return found;
}
Starting at this component in the View hierarchy, search for a
component with a clientId equal to the argument
clientId and, if found, call the ContextCallback#invokeContextCallback method on the argument
callback , passing the current FacesContext
and the found component as arguments. This method is similar to
#findComponent but it does not support the leading UINamingContainer#getSeparatorChar 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, call the ContextCallback#invokeContextCallback method on the argument callback,
passing through the FacesContext argument and
passing this as the component argument. 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 #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
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 #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;
}
});
}
|
public static boolean isCompositeComponent(UIComponent component) {
if (component == null) {
throw new NullPointerException();
}
return (component.getAttributes().containsKey(Resource.COMPONENT_RESOURCE_KEY));
}
Return true if
component is a composite component, otherwise
false .
|
public boolean isInView() {
return isInView;
}
|
abstract public boolean isRendered()
Return true if this component (and its children)
should be rendered during the Render Response phase
of the request processing lifecycle.
|
protected boolean isVisitable(VisitContext context) {
// VisitHints currently defines two hints that affect
// visitability: VIIST_RENDERED and VISIT_TRANSIENT.
// Check for both of these and if set, verify that
// we comply.
Set< VisitHint > hints = context.getHints();
if ((hints.contains(VisitHint.SKIP_UNRENDERED) &&
!this.isRendered()) ||
(hints.contains(VisitHint.SKIP_TRANSIENT) &&
this.isTransient())) {
return false;
}
return true;
}
Return true if this
component should be visited, false otherwise.
Called by UIComponent.visitTree()
to determine whether this component satisfies the hints returned
by javax.faces.component.visit.VisitContext#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 {@code visitTree()} implementations may call this
method to determine whether the component is visitable before
performing any visit-related processing.
|
public void markInitialState() {
initialState = true;
}
|
public final void popComponentFromEL(FacesContext context) {
if (context == null) {
throw new NullPointerException();
}
if (depth > 0) {
depth--;
return;
}
Map< Object,Object > contextMap = context.getAttributes();
if (contextMap != null) {
if (!pushed) {
return;
}
UIComponent c;
pushed = false;
if (previouslyPushed != null) {
c = (UIComponent) contextMap.put(CURRENT_COMPONENT, previouslyPushed);
} else {
c = (UIComponent) contextMap.remove(CURRENT_COMPONENT);
}
if (c != null && UIComponent.isCompositeComponent(c)) {
if (previouslyPushedCompositeComponent != null) {
contextMap.put(CURRENT_COMPOSITE_COMPONENT,
previouslyPushedCompositeComponent);
} else {
contextMap.remove(CURRENT_COMPOSITE_COMPONENT);
}
}
}
}
Pop the current
UIComponent from the FacesContext attributes map
so that the previous UIComponent , if any, becomes the current
component.
|
abstract public void processDecodes(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.
- If the
rendered property of this UIComponent
is false , skip further processing.
- Call #pushComponentToEL .
- Call the
processDecodes() method of all facets
and children of this UIComponent , in the order determined
by a call to getFacetsAndChildren() .
- Call the
decode() method of this component.
- Call #popComponentFromEL from inside of a
finally block, just before returning.
- If a
RuntimeException is thrown during
decode processing, call FacesContext#renderResponse
and re-throw the exception.
|
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
if (event instanceof PostRestoreStateEvent) {
assert(this == event.getComponent());
// if this component has a component value reference expression,
// make sure to populate the ValueExpression for it.
ValueExpression valueExpression;
if (null != (valueExpression = this.getValueExpression("binding"))) {
valueExpression.setValue(FacesContext.getCurrentInstance().getELContext(),
this);
}
}
}
The default implementation performs
the following action. If the argument event is an
instance of PostRestoreStateEvent , call
this. #getValueExpression 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 .
|
abstract public void processRestoreState(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.
This method may not be called if the state saving method is
set to server.
|
abstract public Object processSaveState(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.
- consult the
transient property of this
component. If true, just return null .
- Call #pushComponentToEL .
- Call the
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 #popComponentFromEL 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.
|
abstract public void processUpdates(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.
- If the
rendered property of this UIComponent is false , skip further processing.
- Call #pushComponentToEL .
- Call the
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
|
abstract public void processValidators(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.
- If the
rendered property of this UIComponent
is false , skip further processing.
- Call #pushComponentToEL .
- Call the
processValidators() method of all facets
and children of this UIComponent , in the order determined
by a call to getFacetsAndChildren() .
|
public final void pushComponentToEL(FacesContext context,
UIComponent component) {
if (context == null) {
throw new NullPointerException();
}
if (null == component) {
component = this;
}
Map< Object,Object > contextMap = context.getAttributes();
if (contextMap.get(CURRENT_COMPONENT) == component) {
depth++;
return;
}
if (contextMap.get(CURRENT_COMPOSITE_COMPONENT) == component) {
depth++;
return;
}
pushed = true;
previouslyPushed = (UIComponent) contextMap.put(CURRENT_COMPONENT, component);
// If this is a composite component...
if (UIComponent.isCompositeComponent(component)) {
// make it so #{cc} resolves to this composite
// component, preserving the previous value if present
previouslyPushedCompositeComponent =
(UIComponent) contextMap.put(CURRENT_COMPOSITE_COMPONENT, component);
}
}
Push the current
UIComponent this to the FacesContext
attribute map using the key #CURRENT_COMPONENT saving the previous
UIComponent associated with #CURRENT_COMPONENT for a
subsequent call to #popComponentFromEL .
This method and popComponentFromEL() form the basis for
the contract that enables the EL Expression "#{component} " to
resolve to the "current" component that is being processed in the
lifecycle. The requirements for when pushComponentToEL() and
popComponentFromEL() must be called are specified as
needed in the javadoc for this class.
After
pushComponentToEL() returns, a call to #getCurrentComponent must return this
UIComponent instance until
popComponentFromEL() is called, after which point
the previous UIComponent instance will be returned
from getCurrentComponent()
|
abstract public void queueEvent(FacesEvent event)
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 .
|
abstract protected void removeFacesListener(FacesListener listener)
Remove the specified FacesListener from the set of listeners
registered to receive event notifications from this UIComponent .
|
abstract public void setId(String id)
Set 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
UIComponent that is a NamingContainer , or within
the scope of the entire component tree if there is no such
ancestor that is a NamingContainer .
|
public void setInView(boolean isInView) {
this.isInView = 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 child List
or facet Map .
|
abstract public void setParent(UIComponent parent)
|
abstract public void setRendered(boolean rendered)
|
abstract public void setRendererType(String rendererType)
|
abstract public void setValueBinding(String name,
ValueBinding binding)Deprecated! This - has been replaced by #setValueExpression .
|
public void setValueExpression(String name,
ValueExpression binding) {
if (name == null) {
throw new NullPointerException();
} else if ("id".equals(name) || "parent".equals(name)) {
throw new IllegalArgumentException();
}
if (binding != null) {
if (!binding.isLiteralText()) {
//if (bindings == null) {
// //noinspection CollectionWithoutInitialCapacity
// bindings = new HashMap< String, ValueExpression >();
//}
// add this binding name to the 'attributesThatAreSet' list
//List< String > sProperties = (List< String >)
// getStateHelper().get(PropertyKeysPrivate.attributesThatAreSet);
List< String > sProperties =
(List< String >) getStateHelper().get(PropertyKeysPrivate.attributesThatAreSet);
if (sProperties == null) {
getStateHelper().add(PropertyKeysPrivate.attributesThatAreSet, name);
} else if (!sProperties.contains(name)) {
getStateHelper().add(PropertyKeysPrivate.attributesThatAreSet, name);
}
getStateHelper().put(UIComponentBase.PropertyKeys.bindings,
name,
binding);
//bindings.put(name, binding);
} else {
ELContext context =
FacesContext.getCurrentInstance().getELContext();
try {
getAttributes().put(name, binding.getValue(context));
} catch (ELException ele) {
throw new FacesException(ele);
}
}
} else {
//if (bindings != null) {
// remove this binding name from the 'attributesThatAreSet' list
// List< String > sProperties = getAttributesThatAreSet(false);
// if (sProperties != null) {
// sProperties.remove(name);
// }
getStateHelper().remove(PropertyKeysPrivate.attributesThatAreSet,
name);
getStateHelper().remove(UIComponentBase.PropertyKeys.bindings, name);
//bindings.remove(name);
// if (bindings.isEmpty()) {
// bindings = null;
// }
}
// }
}
Set the ValueExpression used to calculate the value
for the specified attribute or property name, if any.
The implementation must call ValueExpression#isLiteralText on the argument
expression . If isLiteralText() returns
true , invoke ValueExpression#getValue on the
argument expression and pass the result as the value
parameter in a call to this.#getAttributes() .put(name, value) where name
is the argument name . If an exception is thrown as
a result of calling ValueExpression#getValue , wrap it in
a javax.faces.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.
|
public void subscribeToEvent(Class<SystemEvent> eventClass,
ComponentSystemEventListener componentListener) {
if (eventClass == null) {
throw new NullPointerException();
}
if (componentListener == null) {
throw new NullPointerException();
}
if (initialStateMarked()) {
initialState = false;
}
if (null == listenersByEventClass) {
listenersByEventClass = new HashMap< Class< ? extends SystemEvent >,
List< SystemEventListener > >(3, 1.0f);
}
SystemEventListener facesLifecycleListener =
new ComponentSystemEventListenerAdapter(componentListener, this);
List< SystemEventListener > listenersForEventClass =
listenersByEventClass.get(eventClass);
if (listenersForEventClass == null) {
listenersForEventClass = new ArrayList< SystemEventListener >(3);
listenersByEventClass.put(eventClass, listenersForEventClass);
}
if (!listenersForEventClass.contains(facesLifecycleListener)) {
listenersForEventClass.add(facesLifecycleListener);
}
}
Install the listener instance
referenced by argument componentListener as a
listener for events of type eventClass originating
from this specific instance of UIComponent . The
default implementation creates an inner SystemEventListener instance that wraps argument
componentListener as the listener
argument. This inner class must call through to the argument
componentListener in its implementation of SystemEventListener#processEvent and its implementation of
SystemEventListener#isListenerForSource must return
true if the instance class of this UIComponent is
assignable from the argument to
isListenerForSource .
|
public void unsubscribeFromEvent(Class<SystemEvent> eventClass,
ComponentSystemEventListener componentListener) {
if (eventClass == null) {
throw new NullPointerException();
}
if (componentListener == null) {
throw new NullPointerException();
}
List< SystemEventListener > listeners =
getListenersForEventClass(eventClass);
if (listeners != null && !listeners.isEmpty()) {
for (Iterator< SystemEventListener > i = listeners.iterator(); i.hasNext();) {
SystemEventListener item = i.next();
ComponentSystemEventListenerAdapter csla =
(ComponentSystemEventListenerAdapter) item;
ComponentSystemEventListener l = csla.getWrapped();
if (l.equals(componentListener)) {
i.remove();
break;
}
}
}
}
Remove the listener instance
referenced by argument componentListener as a
listener for events of type eventClass
originating from this specific instance of
UIComponent . When doing the comparison to
determine if an existing listener is equal to the argument
componentListener (and thus must be removed),
the equals() method on the existing
listener must be invoked, passing the argument
componentListener , rather than the other way
around.
|
public boolean visitTree(VisitContext context,
VisitCallback callback) {
// First check to see whether we are visitable. If not
// short-circuit out of this subtree, though allow the
// visit to proceed through to other subtrees.
if (!isVisitable(context))
return false;
// Push ourselves to EL before visiting
FacesContext facesContext = context.getFacesContext();
pushComponentToEL(facesContext, null);
try {
// Visit ourselves. Note that we delegate to the
// VisitContext to actually perform the visit.
VisitResult result = context.invokeVisitCallback(this, callback);
// If the visit is complete, short-circuit out and end the visit
if (result == VisitResult.COMPLETE)
return true;
// Visit children if necessary
if (result == VisitResult.ACCEPT) {
Iterator< UIComponent > kids = this.getFacetsAndChildren();
while(kids.hasNext()) {
boolean done = kids.next().visitTree(context, callback);
// If any kid visit returns true, we are done.
if (done)
return true;
}
}
}
finally {
// Pop ourselves off the EL stack
popComponentFromEL(facesContext);
}
// Return false to allow the visit to continue
return false;
}
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 to invoke the callback. This
allows {@code VisitContext} implementations to provide optimized
tree traversals, for example by only calling the {@code
VisitCallback} for a subset of components.
UIComponent.visitTree() implementations must call
UIComponent.pushComponentToEL() before performing the
visit and UIComponent.popComponentFromEL() after the
visit.
|