Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one
    * or more contributor license agreements.  See the NOTICE file
    * distributed with this work for additional information
    * regarding copyright ownership.  The ASF licenses this file
    * to you under the Apache License, Version 2.0 (the
    * "License"); you may not use this file except in compliance
    * with the License.  You may obtain a copy of the License at
    *
   *   http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing,
   * software distributed under the License is distributed on an
   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   * KIND, either express or implied.  See the License for the
   * specific language governing permissions and limitations
   * under the License.
  */
  package javax.faces.component;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  
Standard implementation of the UIComponent base class; all standard JSF components extend this class.

Disclaimer: The official definition for the behaviour of this class is the JSF 1.1 specification but for legal reasons the specification cannot be replicated here. Any javadoc here therefore describes the current implementation rather than the spec, though this class has been verified as correctly implementing the spec. see Javadoc of JSF Specification for more.

Author(s):
Manfred Geiler (latest modification by $Author: grantsmith $)
Version:
$Revision: 472555 $ $Date: 2006-11-08 18:30:58 +0100 (Mi, 08 Nov 2006) $
  
  public abstract class UIComponentBase
          extends UIComponent
  {
      private static Log log = LogFactory.getLog(UIComponentBase.class);
  
      private _ComponentAttributesMap _attributesMap = null;
      private Map _valueBindingMap = null;
      private List _childrenList = null;
      private Map _facetMap = null;
      private List _facesListeners = null;
      private String _clientId = null;
      private String _id = null;
      private UIComponent _parent = null;
      private boolean _transient = false;
  
  
      public UIComponentBase()
      {
      }

    
Get a map through which all the UIComponent's properties, value-bindings and non-property attributes can be read and written.

When writing to the returned map:

  • If this component has an explicit property for the specified key then the setter method is called. An IllegalArgumentException is thrown if the property is read-only. If the property is readable then the old value is returned, otherwise null is returned.
  • Otherwise the key/value pair is stored in a map associated with the component.
Note that value-bindings are not written by put calls to this map. Writing to the attributes map using a key for which a value-binding exists will just store the value in the attributes map rather than evaluating the binding, effectively "hiding" the value-binding from later attributes.get calls. Setter methods on components commonly do not evaluate a binding of the same name; they just store the provided value directly on the component.

When reading from the returned map:

  • If this component has an explicit property for the specified key then the getter method is called. If the property exists, but is read-only (ie only a setter method is defined) then an IllegalArgumentException is thrown.
  • If the attribute map associated with the component has an entry with the specified key, then that is returned.
  • If this component has a value-binding for the specified key, then the value-binding is evaluated to fetch the value.
  • Otherwise, null is returned.
Note that components commonly define getter methods such that they evaluate a value-binding of the same name if there isn't yet a local property.

Assigning values to the map which are not explicit properties on the underlying component can be used to "tunnel" attributes from the JSP tag (or view-specific equivalent) to the associated renderer without modifying the component itself.

Any value-bindings and non-property attributes stored in this map are automatically serialized along with the component when the view is serialized.

 
     public Map getAttributes()
     {
         if ( == null)
         {
              = new _ComponentAttributesMap(this);
         }
         return ;
     }

    
Get the named value-binding associated with this component.

Value-bindings are stored in a map associated with the component, though there is commonly a property (setter/getter methods) of the same name defined on the component itself which evaluates the value-binding when called.

 
     public ValueBinding getValueBinding(String name)
     {
         if (name == nullthrow new NullPointerException("name");
         if ( == null)
         {
             return null;
         }
         else
         {
             return (ValueBinding).get(name);
         }
     }

    
Put the provided value-binding into a map of value-bindings associated with this component.
 
     public void setValueBinding(String name,
                                 ValueBinding binding)
     {
         if (name == nullthrow new NullPointerException("name");
         if ( == null)
         {
              = new HashMap();
         }
         .put(namebinding);
     }

    
Get a string which can be output to the response which uniquely identifies this UIComponent within the current view.

The component should have an id attribute already assigned to it; however if the id property is currently null then a unique id is generated and set for this component. This only happens when components are programmatically created without ids, as components created by a ViewHandler should be assigned ids when they are created.

If this component is a descendant of a NamingContainer then the client id is of form "{namingContainerId}:{componentId}". Note that the naming container's id may itself be of compound form if it has an ancestor naming container. Note also that this only applies to naming containers; other UIComponent types in the component's ancestry do not affect the clientId.

Finally the renderer associated with this component is asked to convert the id into a suitable form. This allows escaping of any characters in the clientId which are significant for the markup language generated by that renderer.

 
     public String getClientId(FacesContext context)
     {
         if (context == nullthrow new NullPointerException("context");
 
         if ( != nullreturn ;
 
         boolean idWasNull = false;
         String id = getId();
         if (id == null)
         {
             //Although this is an error prone side effect, we automatically create a new id
             //just to be compatible to the RI
             UIViewRoot viewRoot = context.getViewRoot();
             if (viewRoot != null)
             {
                 id = viewRoot.createUniqueId();
             }
             else
             {
                 context.getExternalContext().log("ERROR: Cannot automatically create an id for component of type " + getClass().getName() + " because there is no viewRoot in the current facesContext!");
                 id = "ERROR";
             }
             setId(id);
             //We remember that the id was null and log a warning down below
             idWasNull = true;
         }
 
         UIComponent namingContainer = _ComponentUtils.findParentNamingContainer(thisfalse);
         if (namingContainer != null)
         {
              = namingContainer.getClientId(context) + . + id;
         }
         else
         {
              = id;
         }
 
         Renderer renderer = getRenderer(context);
         if (renderer != null)
         {
              = renderer.convertClientId(context);
         }
 
         if (idWasNull)
         {
             context.getExternalContext().log("WARNING: Component " +  + " just got an automatic id, because there was no id assigned yet. " +
                                              "If this component was created dynamically (i.e. not by a JSP tag) you should assign it an " +
                                              "explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot " +
                                              "component right after creation!");
         }
 
         return ;
     }

    
Get a string which uniquely identifies this UIComponent within the scope of the nearest ancestor NamingContainer component. The id is not necessarily unique across all components in the current view.
 
     public String getId()
     {
         return ;
     }

    
Set an identifier for this component which is unique within the scope of the nearest ancestor NamingContainer component. The id is not necessarily unique across all components in the current view.

The id must start with an underscore if it is generated by the JSF framework, and must not start with an underscore if it has been specified by the user (eg in a JSP tag).

The first character of the id must be an underscore or letter. Following characters may be letters, digits, underscores or dashes.

Null is allowed as a parameter, and will reset the id to null.

The clientId of this component is reset by this method; see getClientId for more info.

Throws:
java.lang.IllegalArgumentException if the id is not valid.
 
     public void setId(String id)
     {
         isIdValid(id);
          = id;
          = null;
     }
 
     public UIComponent getParent()
     {
         return ;
     }
 
     public void setParent(UIComponent parent)
     {
          = parent;
     }

    
Indicates whether this component or its renderer manages the invocation of the rendering methods of its child components. When this is true:
  • This component's encodeBegin method will only be called after all the child components have been created and added to this component.
  • This component's encodeChildren method will be called after its encodeBegin method. Components for which this method returns false do not get this method invoked at all.
  • No rendering methods will be called automatically on child components; this component is required to invoke the encodeBegin/encodeEnd/etc on them itself.
 
     public boolean getRendersChildren()
     {
         Renderer renderer = getRenderer(getFacesContext());
         if (renderer != null)
         {
             return renderer.getRendersChildren();
         }
         else
         {
             return false;
         }
     }

    
Return a list of the UIComponent objects which are direct children of this component.

The list object returned has some non-standard behaviour:

  • The list is type-checked; only UIComponent objects can be added.
  • If a component is added to the list with an id which is the same as some other component in the list then an exception is thrown. However multiple components with a null id may be added.
  • The component's parent property is set to this component. If the component already had a parent, then the component is first removed from its original parent's child list.
 
     public List getChildren()
     {
         if ( == null)
         {
              = new _ComponentChildrenList(this);
         }
         return ;
     }

    
Return the number of direct child components this component has.

Identical to getChildren().size() except that when this component has no children this method will not force an empty list to be created.

 
     public int getChildCount()
     {
         return  == null ? 0 : .size();
     }

    
Standard method for finding other components by id, inherited by most UIComponent objects.

The lookup is performed in a manner similar to finding a file in a filesystem; there is a "base" at which to start, and the id can be for something in the "local directory", or can include a relative path. Here, NamingContainer components fill the role of directories, and ":" is the "path separator". Note, however, that although components have a strict parent/child hierarchy, component ids are only prefixed ("namespaced") with the id of their parent when the parent is a NamingContainer.

The base node at which the search starts is determined as follows:

  • When expr starts with ':', the search starts with the root component of the tree that this component is in (ie the ancestor whose parent is null).
  • Otherwise, if this component is a NamingContainer then the search starts with this component.
  • Otherwise, the search starts from the nearest ancestor NamingContainer (or the root component if there is no NamingContainer ancestor).

Parameters:
expr is of form "id1:id2:id3".
Returns:
UIComponent or null if no component with the specified id is found.
 
 
     public UIComponent findComponent(String expr)
     {
         if (expr == nullthrow new NullPointerException("expr");
         if (expr.length() == 0) throw new IllegalArgumentException("empty expr"); //TODO: not specified!
 
         UIComponent findBase;
         if (expr.charAt(0) == .)
         {
             findBase = _ComponentUtils.getRootComponent(this);
             expr = expr.substring(1);
         }
         else
         {
             if (this instanceof NamingContainer)
             {
                 findBase = this;
             }
             else
             {
                 findBase = _ComponentUtils.findParentNamingContainer(thistrue /* root if not found */);
             }
         }
 
         int separator = expr.indexOf(.);
         if (separator == -1)
         {
             return _ComponentUtils.findComponent(findBaseexpr);
         }
         else
         {
             String id = expr.substring(0, separator);
             findBase = _ComponentUtils.findComponent(findBaseid);
             if (findBase == null)
             {
                 return null;
             }
             else
             {
                 if (!(findBase instanceof NamingContainer))
                     throw new IllegalArgumentException("Intermediate identifier " + id + " in search expression " +
                         expr + " identifies a UIComponent that is not a NamingContainer");
                 return findBase.findComponent(expr.substring(separator + 1));
             }
         }
     }
 
 
     public Map getFacets()
     {
         if ( == null)
         {
              = new _ComponentFacetMap(this);
         }
         return ;
     }
 
     public UIComponent getFacet(String name)
     {
         return  == null ? null : (UIComponent).get(name);
     }
 
     public Iterator getFacetsAndChildren()
     {
         return new _FacetsAndChildrenIterator();
     }

    
Invoke any listeners attached to this object which are listening for an event whose type matches the specified event's runtime type.

This method does not propagate the event up to parent components, ie listeners attached to parent components don't automatically get called.

If any of the listeners throws AbortProcessingException then that exception will prevent any further listener callbacks from occurring, and the exception propagates out of this method without alteration.

ActionEvent events are typically queued by the renderer associated with this component in its decode method; ValueChangeEvent events by the component's validate method. In either case the event's source property references a component. At some later time the UIViewRoot component iterates over its queued events and invokes the broadcast method on each event's source object.

Parameters:
event must not be null.
 
     public void broadcast(FacesEvent event)
             throws AbortProcessingException
     {
         if (event == nullthrow new NullPointerException("event");
         if ( == nullreturn;
         for (Iterator it = .iterator(); it.hasNext(); )
         {
             FacesListener facesListener = (FacesListener)it.next();
             if (event.isAppropriateListener(facesListener))
             {
                 event.processListener(facesListener);
             }
         }
     }

    
Check the submitted form parameters for data associated with this component. This default implementation delegates to this component's renderer if there is one, and otherwise ignores the call.
 
     public void decode(FacesContext context)
     {
         if (context == nullthrow new NullPointerException("context");
         Renderer renderer = getRenderer(context);
         if (renderer != null)
         {
             renderer.decode(contextthis);
         }
     }
 
     public void encodeBegin(FacesContext context)
             throws IOException
     {
         if (context == nullthrow new NullPointerException("context");
         if (!isRendered()) return;
         Renderer renderer = getRenderer(context);
         if (renderer != null)
         {
             renderer.encodeBegin(contextthis);
         }
     }
 
     public void encodeChildren(FacesContext context)
             throws IOException
     {
         if (context == nullthrow new NullPointerException("context");
         if (!isRendered()) return;
         Renderer renderer = getRenderer(context);
         if (renderer != null)
         {
             renderer.encodeChildren(contextthis);
         }
     }
 
     public void encodeEnd(FacesContext context)
             throws IOException
     {
         if (context == nullthrow new NullPointerException("context");
         if (!isRendered()) return;
         Renderer renderer = getRenderer(context);
         if (renderer != null)
         {
             renderer.encodeEnd(contextthis);
         }
     }
 
     protected void addFacesListener(FacesListener listener)
     {
         if (listener == nullthrow new NullPointerException("listener");
         if ( == null)
         {
              = new ArrayList();
         }
         .add(listener);
     }
 
     protected FacesListener[] getFacesListeners(Class clazz)
     {
         if ( == null)
         {
             return (FacesListener[])Array.newInstance(clazz, 0);
         }
         List lst = null;
         for (Iterator it = .iterator(); it.hasNext(); )
         {
             FacesListener facesListener = (FacesListener)it.next();
             if (clazz.isAssignableFrom(facesListener.getClass()))
             {
                 if (lst == nulllst = new ArrayList();
                 lst.add(facesListener);
             }
         }
         if (lst == null)
         {
             return (FacesListener[])Array.newInstance(clazz, 0);
         }
         else
         {
             return (FacesListener[])lst.toArray((FacesListener[])Array.newInstance(clazzlst.size()));
         }
     }
 
     protected void removeFacesListener(FacesListener listener)
     {
         if ( != null)
         {
             .remove(listener);
         }
     }
 
     public void queueEvent(FacesEvent event)
     {
         if (event == nullthrow new NullPointerException("event");
         UIComponent parent = getParent();
         if (parent == null)
         {
             throw new IllegalStateException("component is not a descendant of a UIViewRoot");
         }
         parent.queueEvent(event);
     }
 
     public void processDecodes(FacesContext context)
     {
         if (context == nullthrow new NullPointerException("context");
                 if (!isRendered()) return;
         for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
         {
             UIComponent childOrFacet = (UIComponent)it.next();
             childOrFacet.processDecodes(context);
         }
         try
         {
             decode(context);
         }
         catch (RuntimeException e)
         {
             context.renderResponse();
             throw e;
         }
     }
 
 
     public void processValidators(FacesContext context)
     {
         if (context == nullthrow new NullPointerException("context");
         if (!isRendered()) return;
 
         for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
         {
             UIComponent childOrFacet = (UIComponent)it.next();
             childOrFacet.processValidators(context);
         }
     }

    
This isn't an input component, so just pass on the processUpdates call to child components and facets that might be input components.

Components that were never rendered can't possibly be receiving update data (no corresponding fields were ever put into the response) so if this component is not rendered then this method does not invoke processUpdates on its children.

 
     public void processUpdates(FacesContext context)
     {
         if (context == nullthrow new NullPointerException("context");
         if (!isRendered()) return;
 
         for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
         {
             UIComponent childOrFacet = (UIComponent)it.next();
             childOrFacet.processUpdates(context);
         }
     }
 
     public Object processSaveState(FacesContext context)
     {
         if (context == nullthrow new NullPointerException("context");
         if (isTransient()) return null;
         Map facetMap = null;
         for (Iterator it = getFacets().entrySet().iterator(); it.hasNext(); )
         {
             Map.Entry entry = (Map.Entry)it.next();
             if (facetMap == nullfacetMap = new HashMap();
             UIComponent component = (UIComponent)entry.getValue();
             if (!component.isTransient())
             {
                 facetMap.put(entry.getKey(), component.processSaveState(context));
             }
         }
         List childrenList = null;
         if (getChildCount() > 0)
         {
             for (Iterator it = getChildren().iterator(); it.hasNext(); )
             {
               UIComponent child = (UIComponent)it.next();
               if (childrenList == null) {
                 childrenList = new ArrayList(getChildCount());
               }
               Object childState = child.processSaveState(context);
               if (childState != null) {
                 childrenList.add(childState);
               }
             }
         }
         return new Object[] {saveState(context),
                              facetMap,
                              childrenList};
     }
 
     public void processRestoreState(FacesContext context,
                                     Object state)
     {
         if (context == nullthrow new NullPointerException("context");
         Object myState = ((Object[])state)[0];
         Map facetMap = (Map)((Object[])state)[1];
         List childrenList = (List)((Object[])state)[2];
         if(facetMap != null)
         {
           for (Iterator it = getFacets().entrySet().iterator(); it.hasNext(); )
           {
               Map.Entry entry = (Map.Entry)it.next();
               Object facetState = facetMap.get(entry.getKey());
               if (facetState != null)
               {
                 UIComponent component = (UIComponent)entry.getValue();
                 component.processRestoreState(contextfacetState);
               }
               else
               {
                   context.getExternalContext().log("No state found to restore facet " + entry.getKey());
               }
           }
         }
         if (childrenList != null && getChildCount() > 0)
         {
             int idx = 0;
             for (Iterator it = getChildren().iterator(); it.hasNext(); )
             {
                 UIComponent child = (UIComponent)it.next();
                 if(!child.isTransient())
                 {
                   Object childState = childrenList.get(idx++);
                   if (childState != null)
                   {
                       child.processRestoreState(contextchildState);
                   }
                   else
                   {
                       context.getExternalContext().log("No state found to restore child of component " + getId());
                   }
                 }
             }
         }
         restoreState(contextmyState);
     }
 
     protected FacesContext getFacesContext()
     {
         return FacesContext.getCurrentInstance();
     }
 
     protected Renderer getRenderer(FacesContext context)
     {
         if (context == nullthrow new NullPointerException("context");
         String rendererType = getRendererType();
         if (rendererType == nullreturn null;
         String renderKitId = context.getViewRoot().getRenderKitId();
         RenderKit renderKit = rkf.getRenderKit(contextrenderKitId);
         Renderer renderer = renderKit.getRenderer(getFamily(), rendererType);
         if (renderer == null)
         {
             getFacesContext().getExternalContext().log("No Renderer found for component " + getPathToComponent(this) + " (component-family=" + getFamily() + ", renderer-type=" + rendererType + ")");
             .warn("No Renderer found for component " + getPathToComponent(this) + " (component-family=" + getFamily() + ", renderer-type=" + rendererType + ")");
         }
         return renderer;
     }
 
     private String getPathToComponent(UIComponent component)
     {
         StringBuffer buf = new StringBuffer();
 
         if(component == null)
         {
             buf.append("{Component-Path : ");
             buf.append("[null]}");
             return buf.toString();
         }
 
         getPathToComponent(component,buf);
 
         buf.insert(0,"{Component-Path : ");
         buf.append("}");
 
         return buf.toString();
     }
 
     private static void getPathToComponent(UIComponent componentStringBuffer buf)
     {
         if(component == null)
             return;
 
         StringBuffer intBuf = new StringBuffer();
 
         intBuf.append("[Class: ");
         intBuf.append(component.getClass().getName());
         if(component instanceof UIViewRoot)
         {
             intBuf.append(",ViewId: ");
             intBuf.append(((UIViewRootcomponent).getViewId());
         }
         else
         {
             intBuf.append(",Id: ");
             intBuf.append(component.getId());
         }
         intBuf.append("]");
 
         buf.insert(0,intBuf.toString());
 
         getPathToComponent(component.getParent(), buf);
     }
 
     public boolean isTransient()
     {
         return ;
     }
 
     public void setTransient(boolean transientFlag)
     {
          = transientFlag;
     }

    
Serializes objects which are "attached" to this component but which are not UIComponent children of it. Examples are validator and listener objects. To be precise, it returns an object which implements java.io.Serializable, and which when serialized will persist the state of the provided object.

If the attachedObject is a List then every object in the list is saved via a call to this method, and the returned wrapper object contains a List object.

If the object implements StateHolder then the object's saveState is called immediately, and a wrapper is returned which contains both this saved state and the original class name. However in the case where the StateHolder.isTransient method returns true, null is returned instead.

If the object implements java.io.Serializable then the object is simply returned immediately; standard java serialization will later be used to store this object.

In all other cases, a wrapper is returned which simply stores the type of the provided object. When deserialized, a default instance of that type will be recreated.

 
     public static Object saveAttachedState(FacesContext context,
                                            Object attachedObject)
     {
         if (attachedObject == nullreturn null;
         if (attachedObject instanceof List)
         {
             List lst = new ArrayList(((List)attachedObject).size());
             for (Iterator it = ((List)attachedObject).iterator(); it.hasNext(); )
             {
                 lst.add(saveAttachedState(contextit.next()));
             }
             return new _AttachedListStateWrapper(lst);
         }
         else if (attachedObject instanceof StateHolder)
         {
             if (((StateHolder)attachedObject).isTransient())
             {
                 return null;
             }
             else
             {
                 return new _AttachedStateWrapper(attachedObject.getClass(),
                                                  ((StateHolder)attachedObject).saveState(context));
             }
         }
         else if (attachedObject instanceof Serializable)
         {
             return attachedObject;
         }
         else
         {
             return new _AttachedStateWrapper(attachedObject.getClass(), null);
         }
     }
 
     public static Object restoreAttachedState(FacesContext context,
                                               Object stateObj)
             throws IllegalStateException
     {
         if (context == nullthrow new NullPointerException("context");
         if (stateObj == nullreturn null;
         if (stateObj instanceof _AttachedListStateWrapper)
         {
             List lst = ((_AttachedListStateWrapper)stateObj).getWrappedStateList();
             List restoredList = new ArrayList(lst.size());
             for (Iterator it = lst.iterator(); it.hasNext(); )
             {
                 restoredList.add(restoreAttachedState(contextit.next()));
             }
             return restoredList;
         }
         else if (stateObj instanceof _AttachedStateWrapper)
         {
             Class clazz = ((_AttachedStateWrapper)stateObj).getClazz();
             Object restoredObject;
             try
             {
                 restoredObject = clazz.newInstance();
             }
             catch (InstantiationException e)
             {
                 throw new RuntimeException("Could not restore StateHolder of type " + clazz.getName() + " (missing no-args constructor?)"e);
             }
             catch (IllegalAccessException e)
             {
                 throw new RuntimeException(e);
             }
             if (restoredObject instanceof StateHolder)
             {
                 Object wrappedState = ((_AttachedStateWrapper)stateObj).getWrappedStateObject();
                 ((StateHolder)restoredObject).restoreState(contextwrappedState);
             }
             return restoredObject;
         }
         else
         {
             return stateObj;
         }
     }


    
Invoked after the render phase has completed, this method returns an object which can be passed to the restoreState of some other instance of UIComponentBase to reset that object's state to the same values as this object currently has.
 
     public Object saveState(FacesContext context)
     {
         Object values[] = new Object[7];
         values[0] = ;
         values[1] = ;
         values[2] = ;
         values[3] = ;
         values[4] = saveAttributesMap();
         values[5] = saveAttachedState(context);
         values[6] = saveValueBindingMap(context);
         return values;
     }

    
Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into the provided state object.

Parameters:
state is an object previously returned by the saveState method of this class.
 
     public void restoreState(FacesContext contextObject state)
     {
         Object values[] = (Object[])state;
          = (String)values[0];
          = (Boolean)values[1];
          = (String)values[2];
          = (String)values[3];
         restoreAttributesMap(values[4]);
          = (List)restoreAttachedState(contextvalues[5]);
         restoreValueBindingMap(contextvalues[6]);
     }
 
 
     private Object saveAttributesMap()
     {
         if ( != null)
         {
             return .getUnderlyingMap();
         }
         else
         {
             return null;
         }
     }
 
     private void restoreAttributesMap(Object stateObj)
     {
         if (stateObj != null)
         {
              = new _ComponentAttributesMap(this, (Map)stateObj);
         }
         else
         {
              = null;
         }
     }
 
     private Object saveValueBindingMap(FacesContext context)
     {
         if ( != null)
         {
             int initCapacity = (.size() * 4 + 3) / 3;
             HashMap stateMap = new HashMap(initCapacity);
             for (Iterator it = .entrySet().iterator(); it.hasNext(); )
             {
                 Map.Entry entry = (Map.Entry)it.next();
                 stateMap.put(entry.getKey(),
                              saveAttachedState(contextentry.getValue()));
             }
             return stateMap;
         }
         else
         {
             return null;
         }
    }
    private void restoreValueBindingMap(FacesContext contextObject stateObj)
    {
        if (stateObj != null)
        {
            Map stateMap = (Map)stateObj;
            int initCapacity = (stateMap.size() * 4 + 3) / 3;
             = new HashMap(initCapacity);
            for (Iterator it = stateMap.entrySet().iterator(); it.hasNext(); )
            {
                Map.Entry entry = (Map.Entry)it.next();
                .put(entry.getKey(),
                                     restoreAttachedState(contextentry.getValue()));
            }
        }
        else
        {
             = null;
        }
    }


    

Parameters:
string the component id, that should be a vaild one.
    private void isIdValid(String string)
    {
        //is there any component identifier ?
        if(string == null)
            return;
        //Component identifiers must obey the following syntax restrictions:
        //1. Must not be a zero-length String.
        if(string.length()==0)
        {
            throw new IllegalArgumentException("component identifier must not be a zero-length String");
        }
        //let's look at all chars inside of the ID if it is a valid ID!
        char[] chars = string.toCharArray();
        //2. First character must be a letter or an underscore ('_').
        if(!Character.isLetter(chars[0]) &&  chars[0] !='_')
        {
            throw new IllegalArgumentException("component identifier's first character must be a letter or an underscore ('_')! But it is \""+chars[0]+"\"");
        }
        for (int i = 1; i < chars.lengthi++)
        {
            //3. Subsequent characters must be a letter, a digit, an underscore ('_'), or a dash ('-').
            if(!Character.isDigit(chars[i]) && !Character.isLetter(chars[i]) && chars[i] !='-' && chars[i] !='_')
            {
                throw new IllegalArgumentException("Subsequent characters of component identifier must be a letter, a digit, an underscore ('_'), or a dash ('-')! But component identifier contains \""+chars[i]+"\"");
            }
        }
    }
    //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
    private static final boolean DEFAULT_RENDERED = true;
    private Boolean _rendered = null;
    private String _rendererType = null;
    public void setRendered(boolean rendered)
    {
         = Boolean.valueOf(rendered);
    }
    public boolean isRendered()
    {
        if ( != nullreturn .booleanValue();
        ValueBinding vb = getValueBinding("rendered");
        Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
        return v != null ? v.booleanValue() : ;
    }
    public void setRendererType(String rendererType)
    {
         = rendererType;
    }
    public String getRendererType()
    {
        if ( != nullreturn ;
        ValueBinding vb = getValueBinding("rendererType");
        return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
    }
    //------------------ GENERATED CODE END ---------------------------------------
New to GrepCode? Check out our FAQ X