cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r123796 - /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
Date Fri, 31 Dec 2004 14:47:40 GMT
Author: antonio
Date: Fri Dec 31 06:47:39 2004
New Revision: 123796

URL: http://svn.apache.org/viewcvs?view=rev&rev=123796
Log:
Use .equal() to detect ValueChangedEvent()
Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java?view=diff&rev=123796&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java&r1=123795&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java&r2=123796
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
Fri Dec 31 06:47:39 2004
@@ -25,6 +25,7 @@
 import org.xml.sax.SAXException;
 import org.apache.cocoon.forms.validation.ValidationErrorAware;
 import org.apache.cocoon.forms.validation.ValidationError;
+import org.apache.commons.lang.BooleanUtils;
 
 /**
  * A widget to select a boolean value. Usually rendered as a checkbox.
@@ -63,18 +64,14 @@
     }
 
     public void readFromRequest(FormContext formContext) {
-        if (!getCombinedState().isAcceptingInputs())
+        if (!getCombinedState().isAcceptingInputs()) {
             return;
-
+        }
         validationError = null;
         Object oldValue = value;
         String param = formContext.getRequest().getParameter(getRequestParameterName());
-        if (param != null && param.equalsIgnoreCase("true"))
-            value = Boolean.TRUE;
-        else
-            value = Boolean.FALSE;
-
-        if (value != oldValue) {
+        value = BooleanUtils.toBooleanObject(BooleanUtils.toBoolean(param));
+        if (!value.equals(oldValue)) {
             getForm().addWidgetEvent(new ValueChangedEvent(this, oldValue, value));
         }
     }
@@ -141,14 +138,14 @@
         if (object == null) {
             object = Boolean.FALSE;
         }
-        
+
         if (!(object instanceof Boolean)) {
             throw new RuntimeException("Cannot set value of boolean field \"" + getRequestParameterName()
+ "\" to a non-Boolean value.");
         }
-        
+
         Object oldValue = value;
         value = (Boolean)object;
-        if (value != oldValue) {
+        if (!value.equals(oldValue)) {
             getForm().addWidgetEvent(new ValueChangedEvent(this, oldValue, value));
         }
     }

Mime
View raw message