click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r747715 - in /incubator/click/trunk/click/extras/src/org/apache/click/extras/control: CheckList.java PickList.java
Date Wed, 25 Feb 2009 09:13:01 GMT
Author: sabob
Date: Wed Feb 25 09:13:01 2009
New Revision: 747715

URL: http://svn.apache.org/viewvc?rev=747715&view=rev
Log:
added PickList#setSelectedValues and various docs

Modified:
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java?rev=747715&r1=747714&r2=747715&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
Wed Feb 25 09:13:01 2009
@@ -575,8 +575,8 @@
     }
 
     /**
-     * Return the list of selected values. The values are the values of the
-     * Options selected.
+     * Return the list of selected values as a <tt>List</tt> of Strings. The
+     * returned List will contain the values of the Options selected.
      *
      * @deprecated use {@link #getSelectedValues()} instead
      *
@@ -587,8 +587,8 @@
     }
 
     /**
-     * Return the list of selected values. The values are the values of the
-     * Options selected.
+     * Return the list of selected values as a <tt>List</tt> of Strings. The
+     * returned List will contain the values of the Options selected.
      *
      * @return the list of selected values
      */
@@ -602,8 +602,8 @@
     }
 
     /**
-     * Set the list of selected values. The specified values must match
-     * the values of the Options
+     * Set the list of selected values. The specified values must be Strings and
+     * match the values of the Options.
      *
      * @deprecated use {@link #setSelectedValues(List)} instead
      *
@@ -614,8 +614,8 @@
     }
 
     /**
-     * Set the list of selected values. The specified values must match
-     * the values of the Options.
+     * Set the list of selected values. The specified values must be Strings and
+     * match the values of the Options.
      * <p/>
      * For example:
      * <pre class="prettyprint">
@@ -627,6 +627,7 @@
      *     options.add(new Option("2", "Option 2");
      *     options.add(new Option("3", "Option 3");
      *     checkList.setOptionList(options);
+     *     ...
      * }
      *
      * public void onRender() {
@@ -644,26 +645,33 @@
     }
 
     /**
-     * Returns the values list {@link #getValues()} return a list or String.
+     * This method delegates to {@link #getSelectedValues()} to return the
+     * selected values as a <tt>java.util.List</tt> of Strings.
      *
      * @see org.apache.click.control.Field#getValueObject()
+     * @see #getSelectedValues()
      *
-     * @return List of selected values (Strings)
+     * @return selected values as a List of Strings
      */
     public Object getValueObject() {
-        return getValues();
+        return getSelectedValues();
     }
 
     /**
-     * Set the value the value must be a List of String.
+     * This method delegates to {@link #setSelectedValues(java.util.List)}
+     * to set the selected values of the CheckList. The given object parameter
+     * must be a <tt>java.util.List</tt> of Strings, otherwise it is ignored.
+     * <p/>
+     * The List of values match the values of the Options.
      *
      * @see org.apache.click.control.Field#setValueObject(java.lang.Object)
+     * @see #setSelectedValues(java.util.List)
      *
-     * @param object a List or null
+     * @param object a List of Strings
      */
     public void setValueObject(Object object) {
         if (object instanceof List) {
-            setValues((List) object);
+            setSelectedValues((List) object);
         }
     }
 

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java?rev=747715&r1=747714&r2=747715&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java (original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java Wed
Feb 25 09:13:01 2009
@@ -436,9 +436,9 @@
     }
 
     /**
-     * Add the selected value.
+     * Add the selected value to the List of {@link #selectedValues}.
      *
-     * @param value the selected value
+     * @param value the selected value to add
      * @throws IllegalArgumentException if the value is null
      */
     public void addSelectedValue(String value) {
@@ -450,9 +450,10 @@
     }
 
     /**
-     * Return selected values.
+     * Return the list of selected values as a <tt>List</tt> of Strings. The
+     * returned List will contain the values of the Options selected.
      *
-     * @return selected values
+     * @return selected values as a List of Strings
      */
     public List getSelectedValues() {
         if (selectedValues == null) {
@@ -460,33 +461,65 @@
         }
         return selectedValues;
     }
-    
+
     /**
-     * Returns the values list {@link #getSelectedValues()} return a list or String.
+     * Set the list of selected values. The specified values must be Strings and
+     * match the values of the Options.
+     * <p/>
+     * For example:
+     * <pre class="prettyprint">
+     * PickList pickList = new PickList("languages");
+     *
+     * public void onInit() {
+     *     pickList.add(new Option("005", "Java"));
+     *     pickList.add(new Option("006", "Ruby"));
+     *     pickList.add(new Option("007", "Perl"));
+     *     ...
+     * }
+     *
+     * public void onRender() {
+     *     // Preselect Java and Perl.
+     *     List selected = new ArrayList();
+     *     selected.add("005");
+     *     selected.add("007");
+     *     pickList.setSelectedValues(selected);
+     * } </pre>
+     *
+     * @param selectedValues the list of selected string values or null
+     */
+    public void setSelectedValues(List selectedValues) {
+        this.selectedValues = selectedValues;
+    }
+
+    /**
+     * This method delegates to {@link #getSelectedValues()} to return the
+     * selected values as a <tt>java.util.List</tt> of Strings.
      *
      * @see org.apache.click.control.Field#getValueObject()
+     * @see #getSelectedValues()
      *
-     * @return List of selected values (Strings)
+     * @return selected values as a List of Strings
      */
     public Object getValueObject() {
         return getSelectedValues();
     }
-    
+
     /**
-     * Set the value the value must be a List of String.
+     * This method delegates to {@link #setSelectedValues(java.util.List)}
+     * to set the selected values of the PickList. The given object
+     * parameter must be a <tt>java.util.List</tt> of Strings, otherwise it is
+     * ignored.
+     * <p/>
+     * The List of values match the values of the Options.
      *
      * @see org.apache.click.control.Field#setValueObject(java.lang.Object)
+     * @see #setSelectedValues(java.util.List)
      *
-     * @param object a List or null
+     * @param object a List of Strings
      */
     public void setValueObject(Object object) {
         if (object instanceof List) {
-            getSelectedValues().clear();
-            
-            List list = (List) object;
-            for (int i = 0; i < list.size(); i++) {
-                addSelectedValue((String) list.get(i));
-            }
+            setSelectedValues((List) object);
         }
     }
 



Mime
View raw message