Author: ivaynberg
Date: Sat May 22 19:17:42 2010
New Revision: 947325

URL: http://svn.apache.org/viewvc?rev=947325&view=rev
Log:
allow markup id generation control for CheckBoxMultipleChoice

Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java?rev=947325&r1=947324&r2=947325&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
 Sat May 22 19:17:42 2010
@@ -16,6 +16,9 @@
  */
 package org.apache.wicket.markup.html.form;
 
+import java.util.Collection;
+import java.util.List;
+
 import org.apache.wicket.Page;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupStream;
@@ -24,9 +27,6 @@ import org.apache.wicket.util.convert.IC
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
 
-import java.util.Collection;
-import java.util.List;
-
 
 /**
  * A choice subclass that shows choices via checkboxes.
@@ -362,7 +362,7 @@ public class CheckBoxMultipleChoice<T> e
                        buffer.append(getPrefix());
 
                        String id = getChoiceRenderer().getIdValue(choice, 
index);
-                       final String idAttr = getMarkupId() + "-" + 
getInputName() + "_" + id;
+                       final String idAttr = getCheckBoxMarkupId(id);
 
                        // Add checkbox element
                        buffer.append("<input name=\"");
@@ -401,4 +401,24 @@ public class CheckBoxMultipleChoice<T> e
                        buffer.append(getSuffix());
                }
        }
+
+
+       /**
+        * Creates markup id for the input tag used to generate the checkbox 
for the element with the
+        * specified {...@code id}.
+        * <p>
+        * NOTE It is useful to override this method if the contract for the 
genreated ids should be
+        * fixed, for example in cases when the id generation pattern in this 
method is used to predict
+        * ids by some external javascript. If the contract is fixed in the 
user's code then upgrading
+        * wicket versions will guarantee not to break it should the default 
contract be changed at a
+        * later time.
+        * </p>
+        * 
+        * @param id
+        * @return markup id for the input tag
+        */
+       protected String getCheckBoxMarkupId(String id)
+       {
+               return getMarkupId() + "-" + getInputName() + "_" + id;
+       }
 }


Reply via email to