{
escaped = Strings.escapeMarkup(display);
}
// Allows user to add attributes to the <label..> tag
IValueMap labelAttrs = getAdditionalAttributesForLabel(index, choice);
StringBuilder extraLabelAttributes = new StringBuilder();
if (labelAttrs != null)
{
for (Map.Entry<String, Object> attr : labelAttrs.entrySet())
{
extraLabelAttributes.append(' ')
.append(attr.getKey())
.append("=\"")
.append(attr.getValue())
.append('"');
}
}
switch (labelPosition)
{
case BEFORE:
buffer.append("<label for=\"")
.append(idAttr)
.append('"')
.append(extraLabelAttributes)
.append('>')
.append(escaped)
.append("</label>");
break;
case WRAP_BEFORE:
buffer.append("<label")
.append(extraLabelAttributes)
.append('>')
.append(escaped)
.append(' ');
break;
case WRAP_AFTER:
buffer.append("<label")
.append(extraLabelAttributes)
.append('>');
break;
}
// Add radio tag
buffer.append("<input name=\"")
.append(getInputName())
.append('"')
.append(" type=\"radio\"")
.append((isSelected(choice, index, selected) ? " checked=\"checked\"" : ""))
.append((enabled ? "" : " disabled=\"disabled\""))
.append(" value=\"")
.append(id)
.append("\" id=\"")
.append(idAttr)
.append('"');
// Should a roundtrip be made (have onSelectionChanged called)
// when the option is clicked?
if (wantOnSelectionChangedNotifications())
{
CharSequence url = urlFor(IOnChangeListener.INTERFACE, new PageParameters());
Form<?> form = findParent(Form.class);
if (form != null)
{
buffer.append(" onclick=\"")
.append(form.getJsForInterfaceUrl(url))
.append(";\"");
}
else
{
// NOTE: do not encode the url as that would give
// invalid JavaScript
buffer.append(" onclick=\"window.location.href='")
.append(url)
.append((url.toString().indexOf('?') > -1 ? '&' : '?') + getInputName())
.append('=')
.append(id)
.append("';\"");
}
}
// 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())