cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30351] New: - [PATCH] BooleanField - Convert String to Boolean in setValue
Date Tue, 27 Jul 2004 22:01:18 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30351>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30351

[PATCH] BooleanField - Convert String to Boolean in setValue

           Summary: [PATCH] BooleanField - Convert String to Boolean in
                    setValue
           Product: Cocoon 2
           Version: Current CVS 2.1
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: CocoonForms
        AssignedTo: dev@cocoon.apache.org
        ReportedBy: peter.brant@wicourts.gov


As is, BooleanField cannot load values from an XML file bound to the form since 
Strings are not converted to Booleans.

Index: ./src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.ja
va
===================================================================
RCS file: /home/cvspublic/cocoon-
2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java,v
retrieving revision 1.11
diff -u -r1.11 BooleanField.java
--- ./src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java 
2 Jul 2004 09:17:08 -0000       1.11
+++ ./src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java 
27 Jul 2004 21:55:55 -0000
@@ -141,6 +141,11 @@
             object = Boolean.FALSE;
         }

+        if (object instanceof String)
+        {
+            object = Boolean.valueOf((String)object);
+        }
+
         if (!(object instanceof Boolean)) {
             throw new RuntimeException("Cannot set value of boolean field \"" 
+ getRequestParameterName() + "\" to a non-Boolean value.");
         }

Mime
View raw message