Repository: wicket
Updated Branches:
  refs/heads/wicket-6.x 5d47267e9 -> a92f84472


WICKET-5650 Make is possible to position the choice label before/after/around 
the choice


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/a92f8447
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/a92f8447
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/a92f8447

Branch: refs/heads/wicket-6.x
Commit: a92f8447256235783993ca0ae47678ee97240246
Parents: 5d47267
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Tue Jul 22 14:53:36 2014 +0300
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Tue Jul 22 14:53:36 2014 +0300

----------------------------------------------------------------------
 .../html/form/CheckBoxMultipleChoice.java       |  1 +
 .../html/form/CheckBoxMultipleChoiceTest.java   | 41 +++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/a92f8447/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
index 31a1d88..74d4e14 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
@@ -429,6 +429,7 @@ public class CheckBoxMultipleChoice<T> extends 
ListMultipleChoice<T>
                                        break;
                                case WRAP_AFTER:
                                        buffer.append("<label>");
+                                       break;
                                case WRAP_BEFORE:
                                        buffer.append("<label>");
                                        buffer.append(escaped).append(' ');

http://git-wip-us.apache.org/repos/asf/wicket/blob/a92f8447/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoiceTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoiceTest.java
 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoiceTest.java
index 0a2a0c0..219fedd 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoiceTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoiceTest.java
@@ -145,4 +145,43 @@ public class CheckBoxMultipleChoiceTest extends 
WicketTestCase
                tester.startPage(new TestPage(false, false, false, true));
                tester.assertContains("disabled=\"disabled\"");
        }
-}
\ No newline at end of file
+
+       @Test
+       public void defaultLabelPositionIsAfter() throws Exception
+       {
+               CheckBoxMultipleChoice<Integer> radioChoice = new 
CheckBoxMultipleChoice<Integer>("id", Arrays.asList(1));
+               tester.startComponentInPage(radioChoice);
+
+               tester.assertResultPage("<span wicket:id=\"id\"><input 
name=\"id\" type=\"checkbox\" value=\"0\" id=\"id1-id_0\"/><label 
for=\"id1-id_0\">1</label><br/>\n</span>");
+       }
+
+       @Test
+       public void labelPositionBefore() throws Exception
+       {
+               CheckBoxMultipleChoice<Integer> radioChoice = new 
CheckBoxMultipleChoice<Integer>("id", Arrays.asList(1));
+               
radioChoice.setLabelPosition(AbstractChoice.LabelPosition.BEFORE);
+               tester.startComponentInPage(radioChoice);
+
+               tester.assertResultPage("<span wicket:id=\"id\"><label 
for=\"id1-id_0\">1</label><input name=\"id\" type=\"checkbox\" value=\"0\" 
id=\"id1-id_0\"/><br/>\n</span>");
+       }
+
+       @Test
+       public void labelPositionWrapBefore() throws Exception
+       {
+               CheckBoxMultipleChoice<Integer> radioChoice = new 
CheckBoxMultipleChoice<Integer>("id", Arrays.asList(1));
+               
radioChoice.setLabelPosition(AbstractChoice.LabelPosition.WRAP_BEFORE);
+               tester.startComponentInPage(radioChoice);
+
+               tester.assertResultPage("<span wicket:id=\"id\"><label>1 <input 
name=\"id\" type=\"checkbox\" value=\"0\" 
id=\"id1-id_0\"/></label><br/>\n</span>");
+       }
+
+       @Test
+       public void labelPositionWrapAfter() throws Exception
+       {
+               CheckBoxMultipleChoice<Integer> radioChoice = new 
CheckBoxMultipleChoice<Integer>("id", Arrays.asList(1));
+               
radioChoice.setLabelPosition(AbstractChoice.LabelPosition.WRAP_AFTER);
+               tester.startComponentInPage(radioChoice);
+
+               tester.assertResultPage("<span wicket:id=\"id\"><label><input 
name=\"id\" type=\"checkbox\" value=\"0\" id=\"id1-id_0\"/> 
1</label><br/>\n</span>");
+       }
+}

Reply via email to