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:59:17 UTC

svn commit: r685656 - 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:59:15 2008
New Revision: 685656

URL: http://svn.apache.org/viewvc?rev=685656&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/UISelectBooleanTemplate.java
    myfaces/core/trunk_1.2.x/api/src/main/java-templates/javax/faces/component/UISelectManyTemplate.java
    myfaces/core/trunk_1.2.x/api/src/main/java-templates/javax/faces/component/UISelectOneTemplate.java
Modified:
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectBoolean.java
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectMany.java
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectOne.java

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectBoolean.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectBoolean.java?rev=685656&r1=685655&r2=685656&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectBoolean.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectBoolean.java Wed Aug 13 12:59:15 2008
@@ -23,9 +23,10 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
 
 /**
- *
- * UISelectBoolean is a Comonent which represents a boolean value.
- *
+ * A component that allows the user to select or unselect an object.
+ * <p>
+ * This can also be used to choose between two states such as true/false or on/off.
+ * <p>
  * <h4>Events:</h4>
  * <table border="1" width="100%" cellpadding="3" summary="">
  * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
@@ -36,30 +37,31 @@
  * <tr class="TableRowColor">
  * <td valign="top"><code>javax.faces.event.ValueChangeEvent</code></td>
  * <td valign="top" nowrap></td>
- * <td valign="top">The valueChange event is delivered when the value
-                attribute is changed.</td>
+ * <td valign="top">The valueChange event is delivered when the value attribute is changed.</td>
  * </tr>
  * </table>
+ * <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.
  */
-@JSFComponent
-(defaultRendererType = "javax.faces.Checkbox"
-)
+@JSFComponent(defaultRendererType = "javax.faces.Checkbox")
 public class UISelectBoolean extends UIInput
 {
+    public static final String COMPONENT_TYPE = "javax.faces.SelectBoolean";
+    public static final String COMPONENT_FAMILY = "javax.faces.SelectBoolean";
+
+    public UISelectBoolean()
+    {
+        setRendererType("javax.faces.Checkbox");
+    }
+
+    @Override
+    public String getFamily()
+    {
+        return COMPONENT_FAMILY;
+    }
 
-  static public final String COMPONENT_FAMILY =
-    "javax.faces.SelectBoolean";
-  static public final String COMPONENT_TYPE =
-    "javax.faces.SelectBoolean";
-
-  /**
-   * Construct an instance of the UISelectBoolean.
-   */
-  public UISelectBoolean()
-  {
-    setRendererType("javax.faces.Checkbox");
-  }
-  
     public void setSelected(boolean selected)
     {
         setValue(Boolean.valueOf(selected));
@@ -67,9 +69,11 @@
 
     public boolean isSelected()
     {
-        Boolean value = (Boolean)getSubmittedValue();
-        if( value == null )
-            value = (Boolean)getValue();
+        Boolean value = (Boolean) getSubmittedValue();
+        if (value == null)
+        {
+            value = (Boolean) getValue();
+        }
 
         return value != null ? value.booleanValue() : false;
     }
@@ -79,7 +83,10 @@
      */
     public ValueBinding getValueBinding(String name)
     {
-        if (name == null) throw new NullPointerException("name");
+        if (name == null)
+        {
+            throw new NullPointerException("name");
+        }
         if (name.equals("selected"))
         {
             return super.getValueBinding("value");
@@ -93,10 +100,12 @@
     /**
      * @deprecated Use setValueExpression instead
      */
-    public void setValueBinding(String name,
-                                ValueBinding binding)
+    public void setValueBinding(String name, ValueBinding binding)
     {
-        if (name == null) throw new NullPointerException("name");
+        if (name == null)
+        {
+            throw new NullPointerException("name");
+        }
         if (name.equals("selected"))
         {
             super.setValueBinding("value", binding);
@@ -109,7 +118,10 @@
 
     public ValueExpression getValueExpression(String name)
     {
-        if (name == null) throw new NullPointerException("name");
+        if (name == null)
+        {
+            throw new NullPointerException("name");
+        }
         if (name.equals("selected"))
         {
             return super.getValueExpression("value");
@@ -120,10 +132,12 @@
         }
     }
 
-    public void setValueExpression(String name,
-                                   ValueExpression binding)
+    public void setValueExpression(String name, ValueExpression binding)
     {
-        if (name == null) throw new NullPointerException("name");
+        if (name == null)
+        {
+            throw new NullPointerException("name");
+        }
         if (name.equals("selected"))
         {
             super.setValueExpression("value", binding);
@@ -132,11 +146,5 @@
         {
             super.setValueExpression(name, binding);
         }
-    }    
-
-  @Override
-  public String getFamily()
-  {
-    return COMPONENT_FAMILY;
-  }
+    }
 }

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectMany.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectMany.java?rev=685656&r1=685655&r2=685656&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectMany.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectMany.java Wed Aug 13 12:59:15 2008
@@ -34,9 +34,15 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
 
 /**
- *
- * UISelectMany is a Component which represents a user choice of 0..n values.
- *
+ * Base class for the various component classes that allow a user to select zero or more options
+ * from a set.
+ * <p>
+ * This is not an abstract class; java code can create an instance of this, configure its
+ * rendererType appropriately, and add it to a view. However there is no tag class for this
+ * component, ie it cannot be added directly to a page when using JSP (and other presentation
+ * technologies are expected to behave similarly). Instead, there is a family of subclasses that
+ * extend this base functionality, and they do have tag classes.
+ * <p>
  * <h4>Events:</h4>
  * <table border="1" width="100%" cellpadding="3" summary="">
  * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
@@ -47,31 +53,32 @@
  * <tr class="TableRowColor">
  * <td valign="top"><code>javax.faces.event.ValueChangeEvent</code></td>
  * <td valign="top" nowrap></td>
- * <td valign="top">The valueChange event is delivered when the value
-                attribute is changed.</td>
+ * <td valign="top">The valueChange event is delivered when the value attribute is changed.</td>
  * </tr>
  * </table>
+ * <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.
  */
-@JSFComponent
-(defaultRendererType = "javax.faces.Listbox"
-)
+@JSFComponent(defaultRendererType = "javax.faces.Listbox")
 public class UISelectMany extends UIInput
 {
+    public static final String COMPONENT_TYPE = "javax.faces.SelectMany";
+    public static final String COMPONENT_FAMILY = "javax.faces.SelectMany";
 
-  static public final String COMPONENT_FAMILY =
-    "javax.faces.SelectMany";
-  static public final String COMPONENT_TYPE =
-    "javax.faces.SelectMany";
-
-  /**
-   * Construct an instance of the UISelectMany.
-   */
-  public UISelectMany()
-  {
-    setRendererType("javax.faces.Listbox");
-  }
-      public static final String INVALID_MESSAGE_ID = "javax.faces.component.UISelectMany.INVALID";
+    public static final String INVALID_MESSAGE_ID = "javax.faces.component.UISelectMany.INVALID";
 
+    public UISelectMany()
+    {
+        setRendererType("javax.faces.Listbox");
+    }
+
+    @Override
+    public String getFamily()
+    {
+        return COMPONENT_FAMILY;
+    }
 
     public Object[] getSelectedValues()
     {
@@ -95,7 +102,8 @@
         if (name.equals("selectedValues"))
         {
             return super.getValueBinding("value");
-        } else
+        }
+        else
         {
             return super.getValueBinding(name);
         }
@@ -113,7 +121,8 @@
         if (name.equals("selectedValues"))
         {
             super.setValueBinding("value", binding);
-        } else
+        }
+        else
         {
             super.setValueBinding(name, binding);
         }
@@ -128,7 +137,8 @@
         if (name.equals("selectedValues"))
         {
             return super.getValueExpression("value");
-        } else
+        }
+        else
         {
             return super.getValueExpression(name);
         }
@@ -143,7 +153,8 @@
         if (name.equals("selectedValues"))
         {
             super.setValueExpression("value", binding);
-        } else
+        }
+        else
         {
             super.setValueExpression(name, binding);
         }
@@ -158,26 +169,29 @@
         {
             // one is null, the other not
             return value != null;
-        } else if (value == null)
+        }
+        else if (value == null)
         {
             // one is null, the other not
             return previous != null;
-        } else
+        }
+        else
         {
             if (previous instanceof Object[] && value instanceof Object[])
             {
-                return compareObjectArrays((Object[]) previous,
-                        (Object[]) value);
-            } else if (previous instanceof List && value instanceof List)
+                return compareObjectArrays((Object[]) previous, (Object[]) value);
+            }
+            else if (previous instanceof List && value instanceof List)
             {
                 return compareLists((List) previous, (List) value);
-            } else if (previous.getClass().isArray()
-                    && value.getClass().isArray())
+            }
+            else if (previous.getClass().isArray() && value.getClass().isArray())
             {
                 return comparePrimitiveArrays(previous, value);
-            } else
+            }
+            else
             {
-                //Objects have different classes
+                // Objects have different classes
                 return true;
             }
         }
@@ -188,7 +202,7 @@
         int length = value.length;
         if (previous.length != length)
         {
-            //different length
+            // different length
             return true;
         }
 
@@ -202,8 +216,7 @@
                 if (scoreBoard[j] == false)
                 {
                     Object v = value[j];
-                    if ((p == null && v == null)
-                            || (p != null && v != null && p.equals(v)))
+                    if ((p == null && v == null) || (p != null && v != null && p.equals(v)))
                     {
                         scoreBoard[j] = true;
                         found = true;
@@ -213,7 +226,7 @@
             }
             if (!found)
             {
-                return true; //current element of previous array not found in new array
+                return true; // current element of previous array not found in new array
             }
         }
 
@@ -225,7 +238,7 @@
         int length = value.size();
         if (previous.size() != length)
         {
-            //different length
+            // different length
             return true;
         }
 
@@ -239,8 +252,7 @@
                 if (scoreBoard[j] == false)
                 {
                     Object v = value.get(j);
-                    if ((p == null && v == null)
-                            || (p != null && v != null && p.equals(v)))
+                    if ((p == null && v == null) || (p != null && v != null && p.equals(v)))
                     {
                         scoreBoard[j] = true;
                         found = true;
@@ -250,7 +262,7 @@
             }
             if (!found)
             {
-                return true; //current element of previous List not found in new List
+                return true; // current element of previous List not found in new List
             }
         }
 
@@ -262,7 +274,7 @@
         int length = Array.getLength(value);
         if (Array.getLength(previous) != length)
         {
-            //different length
+            // different length
             return true;
         }
 
@@ -276,8 +288,7 @@
                 if (scoreBoard[j] == false)
                 {
                     Object v = Array.get(value, j);
-                    if ((p == null && v == null)
-                            || (p != null && v != null && p.equals(v)))
+                    if ((p == null && v == null) || (p != null && v != null && p.equals(v)))
                     {
                         scoreBoard[j] = true;
                         found = true;
@@ -287,7 +298,7 @@
             }
             if (!found)
             {
-                return true; //current element of previous array not found in new array
+                return true; // current element of previous array not found in new array
             }
         }
 
@@ -301,7 +312,8 @@
         // verify that iterator was successfully created for convertedValue type
         if (itemValues == null)
         {
-            _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID, new Object[]{_MessageUtils.getLabel(context,this)});
+            _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID, new Object[]
+            { _MessageUtils.getLabel(context, this) });
             setValid(false);
             return;
         }
@@ -311,14 +323,16 @@
         // if UISelectMany is required, then there must be some selected values
         if (isRequired() && !hasValues)
         {
-            if(getRequiredMessage() != null)
+            if (getRequiredMessage() != null)
             {
                 String requiredMessage = getRequiredMessage();
-                context.addMessage(this.getClientId(context),new FacesMessage(FacesMessage.SEVERITY_ERROR,requiredMessage,requiredMessage));
+                context.addMessage(this.getClientId(context), new FacesMessage(
+                        FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage));
             }
             else
             {
-                _MessageUtils.addErrorMessage(context, this, REQUIRED_MESSAGE_ID, new Object[]{_MessageUtils.getLabel(context,this)});
+                _MessageUtils.addErrorMessage(context, this, REQUIRED_MESSAGE_ID, new Object[]
+                { _MessageUtils.getLabel(context, this) });
             }
             setValid(false);
             return;
@@ -338,7 +352,9 @@
             {
                 public Object getConvertedValue(FacesContext context, String value)
                 {
-                    Object convertedValue = UISelectMany.this.getConvertedValue(context, new String[]{value});
+                    Object convertedValue = UISelectMany.this.getConvertedValue(context,
+                            new String[]
+                            { value });
                     if (convertedValue instanceof Collection)
                     {
                         Iterator iter = ((Collection) convertedValue).iterator();
@@ -361,10 +377,10 @@
             {
                 Object itemValue = itemValues.next();
 
-                if (!_SelectItemsUtil.matchValue(context, itemValue,
-                        items.iterator(), converter))
+                if (!_SelectItemsUtil.matchValue(context, itemValue, items.iterator(), converter))
                 {
-                    _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID, new Object[]{_MessageUtils.getLabel(context,this)});
+                    _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID, new Object[]
+                    { _MessageUtils.getLabel(context, this) });
                     setValid(false);
                     return;
                 }
@@ -373,35 +389,35 @@
     }
 
     /**
-     * First part is identical to super.validate except the empty condition.
-     * Second part: iterate through UISelectItem and UISelectItems and check
-     * current values against these items
+     * First part is identical to super.validate except the empty condition. Second part: iterate
+     * through UISelectItem and UISelectItems and check current values against these items
      */
     public void validate(FacesContext context)
     {
-        // TODO : Setting the submitted value to null in the super class causes a bug, if set to null, you'll get the following error :
-        // java.lang.NullPointerException at org.apache.myfaces.renderkit._SharedRendererUtils.getConvertedUISelectManyValue(_SharedRendererUtils.java:118)
+        // TODO : Setting the submitted value to null in the super class causes a bug, if set to
+        // null, you'll get the following error :
+        // java.lang.NullPointerException at
+        // org.apache.myfaces.renderkit._SharedRendererUtils.getConvertedUISelectManyValue(_SharedRendererUtils.java:118)
         super.validate(context);
     }
 
-    protected Object getConvertedValue(FacesContext context,
-                                       Object submittedValue)
+    protected Object getConvertedValue(FacesContext context, Object submittedValue)
     {
         try
         {
             Renderer renderer = getRenderer(context);
             if (renderer != null)
             {
-                return renderer
-                        .getConvertedValue(context, this,
-                                submittedValue);
-            } else if (submittedValue == null)
+                return renderer.getConvertedValue(context, this, submittedValue);
+            }
+            else if (submittedValue == null)
             {
                 return null;
-            } else if (submittedValue instanceof String[])
+            }
+            else if (submittedValue instanceof String[])
             {
-                return _SharedRendererUtils.getConvertedUISelectManyValue(
-                        context, this, (String[]) submittedValue);
+                return _SharedRendererUtils.getConvertedUISelectManyValue(context, this,
+                        (String[]) submittedValue);
             }
         }
         catch (ConverterException e)
@@ -410,9 +426,11 @@
             if (facesMessage != null)
             {
                 context.addMessage(getClientId(context), facesMessage);
-            } else
+            }
+            else
             {
-                _MessageUtils.addErrorMessage(context, this, CONVERSION_MESSAGE_ID, new Object[]{_MessageUtils.getLabel(context,this)});
+                _MessageUtils.addErrorMessage(context, this, CONVERSION_MESSAGE_ID, new Object[]
+                { _MessageUtils.getLabel(context, this) });
             }
             setValid(false);
         }
@@ -424,31 +442,29 @@
         if (convertedValue == null)
         {
             return Collections.EMPTY_LIST.iterator();
-        } else
+        }
+        else
         {
             Class valueClass = convertedValue.getClass();
             if (valueClass.isArray())
             {
                 return new _PrimitiveArrayIterator(convertedValue);
-            } else if (convertedValue instanceof Object[])
+            }
+            else if (convertedValue instanceof Object[])
             {
                 Object[] values = (Object[]) convertedValue;
                 return Arrays.asList(values).iterator();
-            } else if (convertedValue instanceof List)
+            }
+            else if (convertedValue instanceof List)
             {
                 List values = (List) convertedValue;
                 return values.iterator();
-            } else
+            }
+            else
             {
                 // unsupported type for iteration
                 return null;
             }
         }
     }
-
-  @Override
-  public String getFamily()
-  {
-    return COMPONENT_FAMILY;
-  }
 }

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectOne.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectOne.java?rev=685656&r1=685655&r2=685656&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectOne.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UISelectOne.java Wed Aug 13 12:59:15 2008
@@ -22,9 +22,11 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
 
 /**
- *
- * UISelectOne is a Component which represents a user choice of 0..1 value.
- *
+ * Component for choosing one option out of a set of possibilities.
+ * <p>
+ * This component is expected to have children of type UISelectItem or UISelectItems; these define
+ * the set of possible options that the user can choose from.
+ * <p>
  * <h4>Events:</h4>
  * <table border="1" width="100%" cellpadding="3" summary="">
  * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
@@ -35,36 +37,38 @@
  * <tr class="TableRowColor">
  * <td valign="top"><code>javax.faces.event.ValueChangeEvent</code></td>
  * <td valign="top" nowrap></td>
- * <td valign="top">The valueChange event is delivered when the value
-                attribute is changed.</td>
+ * <td valign="top">The valueChange event is delivered when the value attribute is changed.</td>
  * </tr>
  * </table>
+ * <p>
+ * See the javadoc for this class in the
+ * <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
+ * for further details.
  */
-@JSFComponent
-(defaultRendererType = "javax.faces.Menu"
-)
+@JSFComponent(defaultRendererType = "javax.faces.Menu")
 public class UISelectOne extends UIInput
 {
+    public static final String COMPONENT_TYPE = "javax.faces.SelectOne";
+    public static final String COMPONENT_FAMILY = "javax.faces.SelectOne";
 
-  static public final String COMPONENT_FAMILY =
-    "javax.faces.SelectOne";
-  static public final String COMPONENT_TYPE =
-    "javax.faces.SelectOne";
-
-  /**
-   * Construct an instance of the UISelectOne.
-   */
-  public UISelectOne()
-  {
-    setRendererType("javax.faces.Menu");
-  }
-      public static final String INVALID_MESSAGE_ID = "javax.faces.component.UISelectOne.INVALID";
+    public static final String INVALID_MESSAGE_ID = "javax.faces.component.UISelectOne.INVALID";
+
+    public UISelectOne()
+    {
+        setRendererType("javax.faces.Menu");
+    }
+
+    @Override
+    public String getFamily()
+    {
+        return COMPONENT_FAMILY;
+    }
 
     /**
-     * Verify that the result of converting the newly submitted value is
-     * <i>equal</i> to the value property of one of the child SelectItem
-     * objects. If this is not true, a validation error is reported.
-     *
+     * Verify that the result of converting the newly submitted value is <i>equal</i> to the value
+     * property of one of the child SelectItem objects. If this is not true, a validation error is
+     * reported.
+     * 
      * @see javax.faces.component.UIInput#validateValue(javax.faces.context.FacesContext,java.lang.Object)
      */
     protected void validateValue(FacesContext context, Object value)
@@ -87,14 +91,9 @@
         // selected value must match to one of the available options
         if (!_SelectItemsUtil.matchValue(context, value, new _SelectItemsIterator(this), converter))
         {
-            _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID, new Object[]{_MessageUtils.getLabel(context,this)});
+            _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID, new Object[]
+            { _MessageUtils.getLabel(context, this) });
             setValid(false);
         }
     }
-
-  @Override
-  public String getFamily()
-  {
-    return COMPONENT_FAMILY;
-  }
 }