Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * $Id: UIComponent.java,v 1.150.4.3 2007/10/01 20:22:34 rlubke Exp $
    */
   
   /*
    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    * 
    * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    * 
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License. You can obtain
   * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
   * language governing permissions and limitations under the License.
   * 
   * When distributing the software, include this License Header Notice in each
   * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
   * Sun designates this particular file as subject to the "Classpath" exception
   * as provided by Sun in the GPL Version 2 section of the License file that
   * accompanied this code.  If applicable, add the following below the License
   * Header, with the fields enclosed by brackets [] replaced by your own
   * identifying information: "Portions Copyrighted [year]
   * [name of copyright owner]"
   * 
   * Contributor(s):
   * 
   * If you wish your version of this file to be governed by only the CDDL or
   * only the GPL Version 2, indicate your decision by adding "[Contributor]
   * elects to include this software in this distribution under the [CDDL or GPL
   * Version 2] license."  If you don't indicate a single choice of license, a
   * recipient has the option to distribute your version of this file under
   * either the CDDL, the GPL Version 2 or to extend the choice of license to
   * its licensees as provided above.  However, if you add GPL Version 2 code
   * and therefore, elected the GPL Version 2 license, then the option applies
   * only if the new code is made subject to such option by the copyright
   * holder.
   */
  
  package javax.faces.component;
  
  
  import java.util.Arrays;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  

UIComponent is the base class for all user interface components in JavaServer Faces. The set of UIComponent instances associated with a particular request and response are organized into a component tree under a UIViewRoot that represents the entire content of the request or response.

For the convenience of component developers, UIComponentBase provides the default behavior that is specified for a UIComponent, and is the base class for all of the concrete UIComponent "base" implementations. Component writers are encouraged to subclass UIComponentBase, instead of directly implementing this abstract class, to reduce the impact of any future changes to the method signatures.

  
  
  public abstract class UIComponent implements StateHolder {

    
This array represents the packages that can leverage the attributesThatAreSet List for optimized attribute rendering. Hopefully JSF 2.0 will remove the need for this.
  
      private static final String[] OPTIMIZED_PACKAGES = {
            "javax.faces.component",
            "javax.faces.component.html"
      };
  
      static {
          // Sort the array for use with Arrays.binarySearch()
          Arrays.sort();
      }

    
List of attributes that have been set on the component (this may be from setValueExpression, the attributes map, or setters from the concrete HTML components. This allows for faster rendering of attributes as this list is authoratative on what has been set.
 
 
 
     // -------------------------------------------------------------- Attributes
 

    

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.
 
     public abstract Map<StringObjectgetAttributes();
 
 
     // ---------------------------------------------------------------- Bindings
 

    

Call through to getValueExpression(java.lang.String) and examine the result. If the result is an instance of the wrapper class mandated in 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.

Deprecated:
This has been replaced by getValueExpression(java.lang.String).
Parameters:
name Name of the attribute or property for which to retrieve a javax.faces.el.ValueBinding
Throws:
java.lang.NullPointerException if name is null
 
     public abstract ValueBinding getValueBinding(String name);


    

Wrap the argument binding in an implementation of javax.el.ValueExpression and call through to setValueExpression(java.lang.String,javax.el.ValueExpression).

Deprecated:
This has been replaced by setValueExpression(java.lang.String,javax.el.ValueExpression).
Parameters:
name Name of the attribute or property for which to set a javax.faces.el.ValueBinding
binding The javax.faces.el.ValueBinding to set, or null to remove any currently set javax.faces.el.ValueBinding
Throws:
java.lang.IllegalArgumentException if name is one of id or parent
java.lang.NullPointerException if name is null
 
     public abstract void setValueBinding(String nameValueBinding binding);
     
     // The set of ValueExpressions for this component, keyed by property
     // name This collection is lazily instantiated
     // The set of ValueExpressions for this component, keyed by property
     // name This collection is lazily instantiated
     protected Map<String,ValueExpressionbindings = null;    

    

Return the javax.el.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.

Parameters:
name Name of the attribute or property for which to retrieve a javax.el.ValueExpression
Throws:
java.lang.NullPointerException if name is null
Since:
1.2
 
     public ValueExpression getValueExpression(String name) {
         ValueExpression result = null;
 
         if (name == null) {
             throw new NullPointerException();
         }
         if ( == null) {
             if (!isUIComponentBase()) {
                 ValueBinding binding = getValueBinding(name);
                 if (null != binding) {
                     result = new ValueExpressionValueBindingAdapter(binding);
                     // Cache this for future reference.
                     //noinspection CollectionWithoutInitialCapacity
                      = new HashMap<StringValueExpression>();
                     .put(nameresult);
                 }
             }
             return (result);
         } else {
             return (.get(name));
         }
 
     }

    

Set the javax.el.ValueExpression used to calculate the value for the specified attribute or property name, if any.

The implementation must call javax.el.Expression.isLiteralText() on the argument expression. If isLiteralText() returns true, invoke javax.el.ValueExpression.getValue(javax.el.ELContext) 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 javax.el.ValueExpression.getValue(javax.el.ELContext), 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 ValueExpressions 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.

Parameters:
name Name of the attribute or property for which to set a javax.el.ValueExpression
binding The javax.el.ValueExpression to set, or null to remove any currently set javax.el.ValueExpression
Throws:
java.lang.IllegalArgumentException if name is one of id or parent
java.lang.NullPointerException if name is null
Since:
1.2
 
     public void setValueExpression(String nameValueExpression 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 ( == null) {
                     //noinspection CollectionWithoutInitialCapacity
                      = new HashMap<StringValueExpression>();
                 }
                 // add this binding name to the 'attributesThatAreSet' list
                 List<StringsProperties = getAttributesThatAreSet(true);
                 if (sProperties != null && !sProperties.contains(name)) {
                     sProperties.add(name);
                 }
 
                 .put(namebinding);
             } else {
                 ELContext context =
                     FacesContext.getCurrentInstance().getELContext();
                 try {
                     getAttributes().put(namebinding.getValue(context));
                 } catch (ELException ele) {
                     throw new FacesException(ele);
                 }
             }
         } else {
             if ( != null) {
                 // remove this binding name from the 'attributesThatAreSet' list
                 List<StringsProperties = getAttributesThatAreSet(false);
                 if (sProperties != null) {
                     sProperties.remove(name);
                 }
                 .remove(name);
                 if (.isEmpty()) {
                      = null;
                 }
             }
         }
 
     }
     
     // -------------------------------------------------------------- Properties
 

    

Return a client-side identifier for this component, generating one if necessary. The associated javax.faces.render.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 + NamingContainer.SEPARATOR_CHAR + myId. Call javax.faces.render.Renderer.convertClientId(javax.faces.context.FacesContext,java.lang.String), passing myId, and return the result.

Parameters:
context The javax.faces.context.FacesContext for the current request
Throws:
java.lang.NullPointerException if context is null
 
     public abstract String getClientId(FacesContext 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(javax.faces.context.FacesContext) for usage.

By default, this method will call through to getClientId(javax.faces.context.FacesContext) and return the result.

Throws:
java.lang.NullPointerException if context is null
Since:
1.2
 
     public String getContainerClientId(FacesContext context) {
         if (context == null) {
             throw new NullPointerException();
         }
         return this.getClientId(context);
     }

    

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 javax.faces.render.Renderer for this component instance.

 
     public abstract String getFamily();


    

Return the component identifier of this UIComponent.

 
     public abstract String getId();


    

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.

Parameters:
id The new component identifier, or null to indicate that this UIComponent does not have a component identifier
Throws:
java.lang.IllegalArgumentException if id is not syntactically valid
 
     public abstract void setId(String id);


    

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( ).

 
     public abstract UIComponent getParent();


    

Set the parent UIComponent of this UIComponent. 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.

Parameters:
parent The new parent, or null for the root node of a component tree
 
     public abstract void setParent(UIComponent parent);


    

Return true if this component (and its children) should be rendered during the Render Response phase of the request processing lifecycle.

 
     public abstract boolean isRendered();


    

Set the rendered property of this UIComponent.

Parameters:
rendered If true render this component; otherwise, do not render this component
 
     public abstract void setRendered(boolean rendered);

    
    

Return the javax.faces.render.Renderer type for this UIComponent (if any).

 
     public abstract String getRendererType();


    

Set the javax.faces.render.Renderer type for this UIComponent, or null for components that render themselves.

Parameters:
rendererType Logical identifier of the type of javax.faces.render.Renderer to use, or null for components that render themselves
 
     public abstract void setRendererType(String rendererType);


    

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 javax.faces.render.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).

 
     public abstract boolean getRendersChildren();
     
     
     // This is necessary for JSF components that extend from UIComponent
     // directly rather than extending from UIComponentBase.  Such components
     // may need to have implementations provided for methods that originated
     // from a spec version more recent than the version with which the component
     // complies.  Currently this private property is only consulted in the
     // getValueExpression() method.
     private boolean isUIComponentBase;
     private boolean isUIComponentBaseIsSet = false;
     
     private boolean isUIComponentBase() {
         if (!) {
              = (this instanceof UIComponentBase);
         }
 
         return ;
     }
 
 
     // ------------------------------------------------- Tree Management Methods
 

    

Return a mutable List representing the child UIComponents 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.
 
     public abstract List<UIComponentgetChildren();


    

Return the number of child UIComponents 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.

 
     public abstract int getChildCount();


    

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(javax.faces.context.FacesContext,java.lang.String,javax.faces.component.ContextCallback).

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 NamingContainer.SEPARATOR_CHAR 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.

Parameters:
expr Search expression identifying the UIComponent to be returned
Returns:
the found UIComponent, or null if the component was not found.
Throws:
java.lang.IllegalArgumentException if an intermediate identifier in a search expression identifies a UIComponent that is not a NamingContainer
java.lang.NullPointerException if expr is null
 
     public abstract UIComponent findComponent(String expr);
    
    

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 javax.faces.context.FacesContext and the found component as arguments. This method is similar to findComponent(java.lang.String) but it does not support the leading NamingContainer.SEPARATOR_CHAR 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(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. If an Exception is thrown by the callback, wrap it in a javax.faces.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(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 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;
}
});
}
 

Parameters:
context the javax.faces.context.FacesContext for the current request
clientId the client identifier of the component to be passed to the argument callback.
callback an implementation of the Callback interface.
Returns:
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.
Throws:
java.lang.NullPointerException if any of the arguments are null
javax.faces.FacesException if the argument Callback throws an Exception, it is wrapped in a FacesException and re-thrown.
Since:
1.2
 
     
     public boolean invokeOnComponent(FacesContext contextString clientId,
             ContextCallback callbackthrows FacesException {
         if (null == context || null == clientId || null == callback) {
             throw new NullPointerException();
         }
         
         boolean found = false;
         if (clientId.equals(this.getClientId(context))) {
             try {
                 callback.invokeContextCallback(contextthis);
                 return true;
             } catch (Exception e) {
                 throw new FacesException(e);
             }
         } else {
             Iterator<UIComponentitr = this.getFacetsAndChildren();
             
             while (itr.hasNext() && !found) {
                 found = itr.next().invokeOnComponent(contextclientId,
                         callback);
             }
         }
         return found;
     }
 
 
     // ------------------------------------------------ Facet Management Methods
 

    

Return a mutable Map representing the facet UIComponents 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.
 
     public abstract Map<StringUIComponentgetFacets();
    
    

Return the number of facet UIComponents 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().

Since:
1.2
 
     public int getFacetCount() {
         return (getFacets().size());
     }



    

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.

Parameters:
name Name of the desired facet
 
     public abstract UIComponent getFacet(String name);


    

Return an Iterator over the facet followed by child UIComponents 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.

 
     public abstract Iterator<UIComponentgetFacetsAndChildren();
     
     
     // -------------------------------------------- Lifecycle Processing Methods
 

    

Broadcast the specified javax.faces.event.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.

Parameters:
event The javax.faces.event.FacesEvent to be broadcast
Throws:
javax.faces.event.AbortProcessingException Signal the JavaServer Faces implementation that no further processing on the current event should be performed
java.lang.IllegalArgumentException if the implementation class of this javax.faces.event.FacesEvent is not supported by this component
java.lang.NullPointerException if event is null
 
     public abstract void broadcast(FacesEvent event)
         throws AbortProcessingException;


    

Decode any new state of this UIComponent from the request contained in the specified javax.faces.context.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().

Parameters:
context javax.faces.context.FacesContext for the request we are processing
Throws:
java.lang.NullPointerException if context is null
 
     public abstract void decode(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 javax.faces.context.FacesContext.

If a javax.faces.render.Renderer is associated with this UIComponent, the actual encoding will be delegated to javax.faces.render.Renderer.encodeBegin(javax.faces.context.FacesContext,javax.faces.component.UIComponent).

Parameters:
context javax.faces.context.FacesContext for the response we are creating
Throws:
java.io.IOException if an input/output error occurs while rendering
java.lang.NullPointerException if context is null
 
     public abstract void encodeBegin(FacesContext contextthrows IOException;


    

If our rendered property is true, render the child UIComponents of this UIComponent. This method will only be called if the rendersChildren property is true.

If a javax.faces.render.Renderer is associated with this UIComponent, the actual encoding will be delegated to javax.faces.render.Renderer.encodeChildren(javax.faces.context.FacesContext,javax.faces.component.UIComponent).

Parameters:
context javax.faces.context.FacesContext for the response we are creating
Throws:
java.io.IOException if an input/output error occurs while rendering
java.lang.NullPointerException if context is null
 
     public abstract void encodeChildren(FacesContext contextthrows IOException;


    

If our rendered property is true, render the ending of the current state of this UIComponent.

If a javax.faces.render.Renderer is associated with this UIComponent, the actual encoding will be delegated to javax.faces.render.Renderer.encodeEnd(javax.faces.context.FacesContext,javax.faces.component.UIComponent).

Parameters:
context javax.faces.context.FacesContext for the response we are creating
Throws:
java.io.IOException if an input/output error occurs while rendering
java.lang.NullPointerException if context is null
 
     public abstract void encodeEnd(FacesContext contextthrows IOException;

    

If this component returns true from isRendered(), render this component and all its children that return true from isRendered(), regardless of the value of the getRendersChildren() flag.

Throws:
java.io.IOException if an input/output error occurs while rendering
java.lang.NullPointerException if context is null
Since:
1.2
 
     
     public void encodeAll(FacesContext contextthrows IOException {
         if (!isRendered()) {
             return;
         }
 
         encodeBegin(context);
         if (getRendersChildren()) {
             encodeChildren(context);
         }
         else            if (this.getChildCount() > 0) {
                 Iterator kids = getChildren().iterator();
                 while (kids.hasNext()) {
                     UIComponent kid = (UIComponentkids.next();
                     kid.encodeAll(context);
                 }
             }
         
         encodeEnd(context);
     }
 
 
 
     // -------------------------------------------------- Event Listener Methods
 

    

Add the specified javax.faces.event.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);
   }
   ...
 }
 

Parameters:
listener The javax.faces.event.FacesListener to be registered
Throws:
java.lang.NullPointerException if listener is null
 
     protected abstract void addFacesListener(FacesListener listener);


    

Return an array of registered javax.faces.event.FacesListeners that are instances of the specified class. If there are no such registered listeners, a zero-length array is returned. The returned array can be safely be cast to an array strongly typed to an element type of clazz.

Parameters:
clazz Class that must be implemented by a javax.faces.event.FacesListener for it to be returned
Throws:
java.lang.IllegalArgumentException if class is not, and does not implement, javax.faces.event.FacesListener
java.lang.NullPointerException if clazz is null
    protected abstract FacesListener[] getFacesListeners(Class clazz);


    

Remove the specified javax.faces.event.FacesListener from the set of listeners registered to receive event notifications from this UIComponent.

Parameters:
listener The javax.faces.event.FacesListener to be deregistered
Throws:
java.lang.NullPointerException if listener is null
    protected abstract void removeFacesListener(FacesListener listener);


    

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.

Parameters:
event javax.faces.event.FacesEvent to be queued
Throws:
java.lang.IllegalStateException if this component is not a descendant of a UIViewRoot
java.lang.NullPointerException if event is null
    public abstract void queueEvent(FacesEvent event);
    // ------------------------------------------------ Lifecycle Phase Handlers


    

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.

  • Call the processRestoreState() method of all facets and children of this UIComponent in the order determined by a call to getFacetsAndChildren().
  • Call the restoreState() method of this component.

This method may not be called if the state saving method is set to server.

Parameters:
context javax.faces.context.FacesContext for the request we are processing
Throws:
java.lang.NullPointerException if context is null
    public abstract void processRestoreState(FacesContext context,
                                             Object state);


    

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 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.
  • If a RuntimeException is thrown during decode processing, call javax.faces.context.FacesContext.renderResponse() and re-throw the exception.

Parameters:
context javax.faces.context.FacesContext for the request we are processing
Throws:
java.lang.NullPointerException if context is null
    public abstract void processDecodes(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 the processValidators() method of all facets and children of this UIComponent, in the order determined by a call to getFacetsAndChildren().

Parameters:
context javax.faces.context.FacesContext for the request we are processing
Throws:
java.lang.NullPointerException if context is null
    public abstract void processValidators(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 the processUpdates() method of all facets and children of this UIComponent, in the order determined by a call to getFacetsAndChildren().

Parameters:
context javax.faces.context.FacesContext for the request we are processing
Throws:
java.lang.NullPointerException if context is null
    public abstract void processUpdates(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 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.
  • Call the saveState() method of this component.
  • Encapsulate the child state and your state into a Serializable Object and return it.

This method may not be called if the state saving method is set to server.

Parameters:
context javax.faces.context.FacesContext for the request we are processing
Throws:
java.lang.NullPointerException if context is null
    public abstract Object processSaveState(FacesContext context);
    // ----------------------------------------------------- Convenience Methods


    

Convenience method to return the javax.faces.context.FacesContext instance for the current request.

    protected abstract FacesContext getFacesContext();


    

Convenience method to return the javax.faces.render.Renderer instance associated with this component, if any; otherwise, return null.

Parameters:
context javax.faces.context.FacesContext for the current request
    protected abstract Renderer getRenderer(FacesContext context);
    // --------------------------------------------------------- Package Private


    

Parameters:
create true if the list should be created
Returns:
A List of Strings of all the attributes that have been set against this component. If the component isn't in the default javax.faces.component or javax.faces.component.html packages, or create is false, this will return null;
    List<StringgetAttributesThatAreSet(boolean create) {
        String pkg = this.getClass().getPackage().getName();
        if (create && Arrays.binarySearch(pkg) >= 0) {
            if ( == null) {
                 = new ArrayList<String>(6);
            }
        }
        return ;
        
    }
New to GrepCode? Check out our FAQ X