You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2010/05/22 21:17:49 UTC

svn commit: r947326 - /wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java

Author: ivaynberg
Date: Sat May 22 19:17:49 2010
New Revision: 947326

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

Modified:
    wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java

Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java?rev=947326&r1=947325&r2=947326&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java Sat May 22 19:17:49 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;
@@ -25,9 +28,6 @@ import org.apache.wicket.util.string.App
 import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.version.undo.Change;
 
-import java.util.Collection;
-import java.util.List;
-
 
 /**
  * A choice subclass that shows choices via checkboxes.
@@ -411,7 +411,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=\"").append(getInputName()).append("\"").append(
@@ -448,6 +448,25 @@ public class CheckBoxMultipleChoice<T> e
 	}
 
 	/**
+	 * 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;
+	}
+
+	/**
 	 * Overridable method to determine whether the label markup should be escaped.
 	 * 
 	 * @deprecated use {@link #setEscapeModelStrings(boolean)}