You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/08/13 21:36:17 UTC

svn commit: r685651 - in /myfaces/core/trunk_1.2.x/api/src/main: java-templates/javax/faces/component/ java/javax/faces/component/

Author: skitching
Date: Wed Aug 13 12:36:16 2008
New Revision: 685651

URL: http://svn.apache.org/viewvc?rev=685651&view=rev
Log:
Clean up code that was auto-generated via trinidad-faces-plugin during early 1.2.x period.
Remove the no-longer-used template class. 
Add more documentation.
No logic changes made.

Removed:
    myfaces/core/trunk_1.2.x/api/src/main/java-templates/javax/faces/component/UINamingContainerTemplate.java
    myfaces/core/trunk_1.2.x/api/src/main/java-templates/javax/faces/component/UIOutputTemplate.java
Modified:
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/NamingContainer.java
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UINamingContainer.java
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIOutput.java

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/NamingContainer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/NamingContainer.java?rev=685651&r1=685650&r2=685651&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/NamingContainer.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/NamingContainer.java Wed Aug 13 12:36:16 2008
@@ -19,7 +19,40 @@
 package javax.faces.component;
 
 /**
- * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ * Interface implemented by components that provide a new "namespace" for the ids of their
+ * child components.
+ * <p>
+ * Component ids must be unique between all descendants of a NamingContainer; the JSF library
+ * will report a fatal error and refuse to process or render any view where two components
+ * in the same NamingContainer have identical id values. However a component that is a descendant
+ * of one NamingContainer component is permitted to have the same id as a component that is a
+ * descendant of a different NamingContainer component.
+ * <p>
+ * Unique component ids are used to:
+ * <ul>
+ * <li>generate unique names for HTML form fields, etc</li>
+ * <li>search for components via UIComponent.findComponent(String expr)</li>
+ * <li>on re-render after postback, match up component declarations in the view templates
+ * with existing components in the restored view tree.
+ * </ul>
+ * <p>
+ * Requiring every component in a large view (which is possibly built by including or
+ * composing multiple files together) to have an id which is different from every other id
+ * is simply unmanageable; JSF certainly must provide <i>some</i> kind of id namespacing.
+ * Therefore this base class is defined, and a few standard JSF components subclass it
+ * (in particular, f:subview).
+ * <p>
+ * When generating clientId values during rendering, descendants of a NamingContainer instance
+ * are allocated a clientId which is their own id prefixed with the clientId of the ancestor
+ * NamingContainer, eg "parentId:childId". NamingContainer components can be nested within
+ * other NamingContainer components, generating clientIds like "firstId:middleId:leafId". 
+ * <p>
+ * Not every component is a naming container; that would technically work, but the clientId
+ * values generated would quickly grow excessively long.
+ * <p>
+ * See the javadoc for this class in the 
+ * <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ * for further details.
  *
  * @author Manfred Geiler (latest modification by $Author$)
  * @version $Revision$ $Date$

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UINamingContainer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UINamingContainer.java?rev=685651&r1=685650&r2=685651&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UINamingContainer.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UINamingContainer.java Wed Aug 13 12:36:16 2008
@@ -21,28 +21,28 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
 
 /**
+ * Base class for components that provide a new "namespace" for the ids of their
+ * child components.
+ * <p>
+ * See the javadocs for interface NamingContainer for further details.
  */
 @JSFComponent
-public class UINamingContainer extends UIComponentBase
-                               implements NamingContainer
+public class UINamingContainer extends UIComponentBase implements NamingContainer
 {
+    public static final String COMPONENT_TYPE = "javax.faces.NamingContainer";
+    public static final String COMPONENT_FAMILY = "javax.faces.NamingContainer";
 
-  static public final String COMPONENT_FAMILY =
-    "javax.faces.NamingContainer";
-  static public final String COMPONENT_TYPE =
-    "javax.faces.NamingContainer";
+    /**
+     * Construct an instance of the UINamingContainer.
+     */
+    public UINamingContainer()
+    {
+        setRendererType(null);
+    }
 
-  /**
-   * Construct an instance of the UINamingContainer.
-   */
-  public UINamingContainer()
-  {
-    setRendererType(null);
-  }
-
-  @Override
-  public String getFamily()
-  {
-    return COMPONENT_FAMILY;
-  }
+    @Override
+    public String getFamily()
+    {
+        return COMPONENT_FAMILY;
+    }
 }

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIOutput.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIOutput.java?rev=685651&r1=685650&r2=685651&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIOutput.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIOutput.java Wed Aug 13 12:36:16 2008
@@ -25,132 +25,109 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
 
 /**
- *
- * UIOutput displays a value to the user
+ * Displays a value to the user.
  */
-@JSFComponent
-(defaultRendererType = "javax.faces.Text"
-)
-public class UIOutput extends UIComponentBase
-                      implements ValueHolder
+@JSFComponent(defaultRendererType = "javax.faces.Text")
+public class UIOutput extends UIComponentBase implements ValueHolder
 {
+    public static final String COMPONENT_TYPE = "javax.faces.Output";
+    public static final String COMPONENT_FAMILY = "javax.faces.Output";
 
-  static public final String COMPONENT_FAMILY =
-    "javax.faces.Output";
-  static public final String COMPONENT_TYPE =
-    "javax.faces.Output";
-
-  /**
-   * Construct an instance of the UIOutput.
-   */
-  public UIOutput()
-  {
-    setRendererType("javax.faces.Text");
-  }
-      public Object getLocalValue()
+    private Object _value;
+    private Converter _converter;
+
+    /**
+     * Construct an instance of the UIOutput.
+     */
+    public UIOutput()
+    {
+        setRendererType("javax.faces.Text");
+    }
+
+    @Override
+    public String getFamily()
+    {
+        return COMPONENT_FAMILY;
+    }
+
+    public Object getLocalValue()
     {
         return _value;
     }
 
-  // Property: value
-  private Object _value;
+    /**
+     * Gets The initial value of this component.
+     * 
+     * @return the new value value
+     */
+    @JSFProperty
+    public Object getValue()
+    {
+        if (_value != null)
+        {
+            return _value;
+        }
+        ValueExpression expression = getValueExpression("value");
+        if (expression != null)
+        {
+            return expression.getValue(getFacesContext().getELContext());
+        }
+        return null;
+    }
+
+    /**
+     * The initial value of this component.
+     */
+    public void setValue(Object value)
+    {
+        this._value = value;
+    }
+
+    /**
+     * An expression that specifies the Converter for this component.
+     * <p>
+     * The value can either be a static value (ID) or an EL expression. When a static id is
+     * specified, an instance of the converter type registered with that id is used. When this
+     * is an EL expression, the result of evaluating the expression must be an object that
+     * implements the Converter interface.
+     */
+    @JSFProperty
+    public Converter getConverter()
+    {
+        if (_converter != null)
+        {
+            return _converter;
+        }
+        ValueExpression expression = getValueExpression("converter");
+        if (expression != null)
+        {
+            return (Converter) expression.getValue(getFacesContext().getELContext());
+        }
+        return null;
+    }
+
+    public void setConverter(Converter converter)
+    {
+        this._converter = converter;
+    }
+
+    @Override
+    public Object saveState(FacesContext facesContext)
+    {
+        Object[] values = new Object[3];
+        values[0] = super.saveState(facesContext);
+        values[1] = _value;
+        values[2] = saveAttachedState(facesContext, _converter);
+
+        return values;
+    }
 
-  /**
-   * Gets The initial value of this component.
-   *
-   * @return  the new value value
-   */
-  @JSFProperty
-  public Object getValue()
-  {
-    if (_value != null)
-    {
-      return _value;
-    }
-    ValueExpression expression = getValueExpression("value");
-    if (expression != null)
-    {
-      return expression.getValue(getFacesContext().getELContext());
-    }
-    return null;
-  }
-
-  /**
-   * Sets The initial value of this component.
-   * 
-   * @param value  the new value value
-   */
-  public void setValue(Object value)
-  {
-    this._value = value;
-  }
-
-  // Property: converter
-  private Converter _converter;
-
-  /**
-   * Gets An expression that specifies the Converter for this component.
-   *               The value can either be a static value (ID) or an EL expression.
-   *               When a static id is specified, an instance of the converter type
-   *               registered with that id is used. When this is an EL expression,
-   *               the result of evaluating the expression must be an object that
-   *               implements the Converter interface.
-   *
-   * @return  the new converter value
-   */
-  @JSFProperty
-  public Converter getConverter()
-  {
-    if (_converter != null)
-    {
-      return _converter;
-    }
-    ValueExpression expression = getValueExpression("converter");
-    if (expression != null)
-    {
-      return (Converter)expression.getValue(getFacesContext().getELContext());
-    }
-    return null;
-  }
-
-  /**
-   * Sets An expression that specifies the Converter for this component.
-   *               The value can either be a static value (ID) or an EL expression.
-   *               When a static id is specified, an instance of the converter type
-   *               registered with that id is used. When this is an EL expression,
-   *               the result of evaluating the expression must be an object that
-   *               implements the Converter interface.
-   * 
-   * @param converter  the new converter value
-   */
-  public void setConverter(Converter converter)
-  {
-    this._converter = converter;
-  }
-
-  @Override
-  public Object saveState(FacesContext facesContext)
-  {
-    Object[] values = new Object[3];
-    values[0] = super.saveState(facesContext);
-    values[1] = _value;
-    values[2] = saveAttachedState(facesContext, _converter);
-
-    return values;
-  }
-
-  @Override
-  public void restoreState(FacesContext facesContext, Object state)
-  {
-    Object[] values = (Object[])state;
-    super.restoreState(facesContext,values[0]);
-    _value = values[1];
-    _converter = (Converter) restoreAttachedState(facesContext, values[2]);
-  }
-
-  @Override
-  public String getFamily()
-  {
-    return COMPONENT_FAMILY;
-  }
+    @Override
+    public void restoreState(FacesContext facesContext, Object state)
+    {
+        Object[] values = (Object[]) state;
+        super.restoreState(facesContext, values[0]);
+        _value = values[1];
+        _converter = (Converter) restoreAttachedState(facesContext, values[2]);
+    }
 }