You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2010/10/24 11:32:47 UTC
svn commit: r1026755 -
/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
Author: mgrigorov
Date: Sun Oct 24 09:32:46 2010
New Revision: 1026755
URL: http://svn.apache.org/viewvc?rev=1026755&view=rev
Log:
WICKET-2776 Enhancing RadioChoice input items with individual title and css class attributes
Merge from 1.4.x:
and WICKET-2772
Issue: WICKET-2776
Files Changed
MODIFY /wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
ASF #922649 Sat Mar 13 13:50:47 EST 2010 jdonnerstag added additional attributes to allow for index dependent attributes
Issue: WICKET-2776
Files Changed
MODIFY /wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java?rev=1026755&r1=1026754&r2=1026755&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java Sun Oct 24 09:32:46 2010
@@ -17,6 +17,7 @@
package org.apache.wicket.markup.html.form;
import java.util.List;
+import java.util.Map;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
@@ -24,6 +25,7 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.util.convert.IConverter;
import org.apache.wicket.util.string.AppendingStringBuffer;
import org.apache.wicket.util.string.Strings;
+import org.apache.wicket.util.value.IValueMap;
/**
@@ -423,6 +425,34 @@ public class RadioChoice<T> extends Abst
}
}
+ // Allows user to add attributes to the <input..> tag
+ {
+ IValueMap attrs = getAdditionalAttributes(index, choice);
+ if (attrs != null)
+ {
+ for (Map.Entry<String, Object> attr : attrs.entrySet())
+ {
+ buffer.append(" ")
+ .append(attr.getKey())
+ .append("=\"")
+ .append(attr.getValue())
+ .append("\"");
+ }
+ }
+ }
+
+ if (getApplication().getDebugSettings().isOutputComponentPath())
+ {
+ String path = getPageRelativePath();
+ path = path.replace("_", "__");
+ path = path.replace(":", "_");
+ buffer.append(" wicketpath=\"")
+ .append(path)
+ .append("_input_")
+ .append(index)
+ .append("\"");
+ }
+
buffer.append("/>");
// Add label for radio button
@@ -452,4 +482,16 @@ public class RadioChoice<T> extends Abst
// Replace body
replaceComponentTagBody(markupStream, openTag, buffer);
}
+
+ /**
+ * You may subclass this method to provide additional attributes to the <input ..> tag.
+ *
+ * @param index
+ * @param choice
+ * @return tag attribute name/value pairs.
+ */
+ protected IValueMap getAdditionalAttributes(final int index, final T choice)
+ {
+ return null;
+ }
}