click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bck...@apache.org
Subject svn commit: r1060975 - in /click/trunk/click: documentation/docs/roadmap-changes.html extras/src/org/apache/click/extras/control/CheckList.java extras/test/org/apache/click/extras/control/CheckListTest.java
Date Wed, 19 Jan 2011 20:37:14 GMT
Author: bckfnn
Date: Wed Jan 19 20:37:14 2011
New Revision: 1060975

URL: http://svn.apache.org/viewvc?rev=1060975&view=rev
Log:
fix readonly CheckList to use disabled attribute. CLK-751


Modified:
    click/trunk/click/documentation/docs/roadmap-changes.html
    click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
    click/trunk/click/extras/test/org/apache/click/extras/control/CheckListTest.java

Modified: click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/click/trunk/click/documentation/docs/roadmap-changes.html?rev=1060975&r1=1060974&r2=1060975&view=diff
==============================================================================
--- click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ click/trunk/click/documentation/docs/roadmap-changes.html Wed Jan 19 20:37:14 2011
@@ -357,6 +357,10 @@ Fixed table headers that used incorrect 
               [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-241">CLK-241</a>].
           </li>
           <li class="change">
+              Fixed readonly CheckList to use <tt>disabled</tt> attribute, 
+              same as Checkbox does [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-751">CLK-751</a>].
+          </li>
+          <li class="change">
               Removed the <tt>#FIXED</tt> attributes from the <tt>click.dtd</tt>
               which caused xml validation errors. This issue was raised by Ryan Holmes
               [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-717">CLK-717</a>].

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java?rev=1060975&r1=1060974&r2=1060975&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java Wed Jan 19
20:37:14 2011
@@ -1099,21 +1099,21 @@ public class CheckList extends Field {
                 }
 
                 // set checked status
+                boolean checked = false;
                 List<String> values = getSelectedValues();
                 for (int k = 0; k < values.size(); k++) {
                     if (String.valueOf(values.get(k)).equals(option.getValue())) {
-                        buffer.appendAttribute("checked", "checked");
+                        checked = true;
                     }
                 }
 
-                if (isDisabled()) {
-                    buffer.appendAttributeDisabled();
+                if (checked) {
+                    buffer.appendAttribute("checked", "checked");
                 }
-                if (isReadonly()) {
-                    buffer.appendAttributeReadonly();
+                if (isReadonly() || isDisabled()) {
+                    buffer.appendAttributeDisabled();
                 }
                 buffer.elementEnd();
-
                 buffer.appendEscaped(option.getLabel());
 
                 if (sortable) {
@@ -1122,6 +1122,14 @@ public class CheckList extends Field {
                     buffer.append("</label>");
                 }
 
+                if (checked && (isReadonly() || isDisabled())) {
+                    buffer.elementStart("input");
+                    buffer.appendAttribute("type", "hidden");
+                    buffer.appendAttribute("name", getName());
+                    buffer.appendAttributeEscaped("value", option.getValue());
+                    buffer.elementEnd();
+                }
+
                 // hiddenfield if sortable
 
                 if (sortable) {

Modified: click/trunk/click/extras/test/org/apache/click/extras/control/CheckListTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/test/org/apache/click/extras/control/CheckListTest.java?rev=1060975&r1=1060974&r2=1060975&view=diff
==============================================================================
--- click/trunk/click/extras/test/org/apache/click/extras/control/CheckListTest.java (original)
+++ click/trunk/click/extras/test/org/apache/click/extras/control/CheckListTest.java Wed Jan
19 20:37:14 2011
@@ -19,6 +19,7 @@
 package org.apache.click.extras.control;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.click.control.Option;
@@ -150,4 +151,23 @@ public class CheckListTest extends TestC
         // Perform test
         assertTrue(cl.isValid());
     }
+
+    /**
+     * Check that a readonly CheckList uses diabled attribute instead of
+     * readonly attribute.
+     *
+     * CLK-751
+     */
+    public void testReadonly() {
+        MockContext context = MockContext.initContext();
+        CheckList cl = new CheckList("cl");
+        cl.setReadonly(true);
+        int[] in = {1,2,3,4,5,6};
+        List<Option> ol = createOptionsList(in);
+        cl.setOptionList(ol);
+        cl.setSelectedValues(Arrays.asList("1", "2"));
+        assertFalse(cl.toString().contains("readonly=\"readonly\""));
+        assertTrue(cl.toString().contains("disabled=\"disabled\""));
+        assertTrue(cl.toString().contains("<input type=\"hidden\" name=\"cl\" value=\"1\"/>"));
+    }
 }



Mime
View raw message