I love the simplicity of CheckBoxMultipleChoice, but its markup leaves a
little to be desired. There aren't any label tags, and the lines end
with <br />. Of course the break is easily fixed with calls to
setPrefix("<div>"), setSuffix("</div>"), but since onComponentTagBody()
is final I don't have any way to get at the internal markup. I MUST have
label tags (not so much for the blind as for the haters-of-tiny-buttons,
a group I pledge allegiance to), so I'm left copying & pasting the whole
class to change about 5 lines of code. Gross.
What is up with element IDs, anyway? It seems that Wicket stays away
from them, which is usually fine since you can do whatever you want with
AttributeModifiers. But here I can't, and I suspect that this component
was left without labels because of general element ID shyness. If there
were a webmarkup level method to get a (probably) unique element ID,
then CheckBoxMultipleChoice could do a little extra to make it unique
within its set and then render some labels.
Well, anyway, here are the changes I made to CheckBoxMultipleChoice to
make it churn out labels tied to IDs:
...
private String prefix = "<div>";
private String suffix = "</div>\n";
...
String elementId = "_wicket_" + getInputName() + "_" + id;
...
buffer.append("<input name=\"" + getInputName() + "\""
+ " type=\"checkbox\""
+ (isSelected(choice,index) ? " checked" : "")
+ " value=\"" + id + "\" id=\"" + elementId + "\">");
...
buffer.append("<label for=\"").append(elementId).append("\">")
.append(escaped).append("</label>");
...
It's not art, but it does give me a click area bigger than 10 x 10 pixels.
Nathan
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user