Reviewers: ajr,

Description:
This is intended for 1.6. We decided that setValue(null) is okay for
emptying things, but I neglected to inform TextBoxBase of this fact.
This gets in the way of the 1_6_datepicker merge, where the test that
null is okay was written (I know, I know).

At the same time, CheckBox#setValue(null) should continue to fail, as
the notion of emptying a check box is pretty nonsensical. It is alway
true or false, not true, false, or the-user-hasn't-been-here-yet. This
punches up its javadoc a bit, and makes the param check more ironclad.


Please review this at http://codereview.appspot.com/8904

Affected files:
   user/src/com/google/gwt/user/client/ui/CheckBox.java
   user/src/com/google/gwt/user/client/ui/TextBoxBase.java


Index: user/src/com/google/gwt/user/client/ui/CheckBox.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/CheckBox.java        (revision 4222)
+++ user/src/com/google/gwt/user/client/ui/CheckBox.java        (working copy)
@@ -135,6 +135,11 @@
      return DOM.getInnerText(labelElem);
    }

+  /**
+   * Determines whether this check box is currently checked.
+   *
+   * @return <code>true</code> if the check box is checked
+   */
    public Boolean getValue() {
      return isChecked();
    }
@@ -163,7 +168,7 @@
     * Checks or unchecks this check box. Does not fire [EMAIL PROTECTED]  
ValueChangeEvent}.
     * (If you want the event to fire, use [EMAIL PROTECTED] #setValue(boolean, 
 
boolean)})
     *
-   * @param checked <code>true</code> to check the check box
+   * @param checked <code>true</code> to check the check box.
     */
    public void setChecked(boolean checked) {
      DOM.setElementPropertyBoolean(inputElem, "checked", checked);
@@ -214,12 +219,29 @@
      DOM.setInnerText(labelElem, text);
    }

+  /**
+   * Checks or unchecks the text box.
+   * @param value true to check, false to uncheck. Must not be null.
+   * @thows IllegalArgumentException if value is null
+   */
    public void setValue(Boolean value) {
      setValue(value, false);
    }

+  /**
+   * Checks or unchecks the text box, firing [EMAIL PROTECTED] 
ValueChangeEvent}
+   * if appropriate.
+   *
+   * @param value true to check, false to uncheck. Must not be null.
+   * @param fireEvents If true, and value has changed, fire a
+   * [EMAIL PROTECTED] ValueChangeEvent}
+   * @thows IllegalArgumentException if value is null
+   */
    public void setValue(Boolean value, boolean fireEvents) {
-    assert null != value : "Value must not be null";
+    if (value == null) {
+      throw new IllegalArgumentException("value must not be null");
+    }
+
      if (isChecked() == value) {
        return;
      }
Index: user/src/com/google/gwt/user/client/ui/TextBoxBase.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/TextBoxBase.java     (revision 4222)
+++ user/src/com/google/gwt/user/client/ui/TextBoxBase.java     (working copy)
@@ -301,7 +301,6 @@
    }

    public void setValue(String value, boolean fireEvents) {
-    assert null != value : "Value must not be null";
      String oldValue = getText();
      setText(value);
      if (fireEvents) {



--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to