if (!(component instanceof UISelectOne)) {
LOG.error("Wrong type: Need " + UISelectOne.class.getName() + ", but was " + component.getClass().getName());
return;
}
UISelectOne selectOne = (UISelectOne) component;
String clientId = selectOne.getClientId(facesContext);
ComponentUtil.findPage(facesContext, selectOne)
.getOnloadScripts().add("Tobago.selectOneRadioInit('" + clientId + "')");
if (LOG.isDebugEnabled()) {
for (Object o : selectOne.getChildren()) {
LOG.debug("ITEMS " + o);
if (o instanceof UISelectItems) {
UISelectItems uiitems = (UISelectItems) o;
Object v = uiitems.getValue();
LOG.debug("VALUE " + v);
if (v != null) {
LOG.debug("VALUE " + v.getClass().getName());
}
}
}
}
List<SelectItem> items = ComponentUtil.getItemsToRender(selectOne);
boolean inline = ComponentUtil.getBooleanAttribute(selectOne, ATTR_INLINE);
String title = HtmlRendererUtil.getTitleFromTipAndMessages(facesContext, selectOne);
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
if (!inline) {
writer.startElement(HtmlConstants.TABLE, selectOne);
// TODO writer.writeComponentClass();
writer.writeAttribute(HtmlAttributes.BORDER, 0);
writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
writer.writeStyleAttribute();
if (title != null) {
writer.writeAttribute(HtmlAttributes.TITLE, title, true);
}
}
boolean disabled = ComponentUtil.getBooleanAttribute(selectOne, ATTR_DISABLED);
boolean readonly = ComponentUtil.getBooleanAttribute(selectOne, ATTR_READONLY);
Object value = selectOne.getValue();
List<String> clientIds = new ArrayList<String>();
for (SelectItem item : items) {
if (!inline) {
writer.startElement(HtmlConstants.TR, null);
writer.startElement(HtmlConstants.TD, null);
}
String id = clientId + NamingContainer.SEPARATOR_CHAR
+ NamingContainer.SEPARATOR_CHAR + item.getValue().toString();
clientIds.add(id);
writer.startElement(HtmlConstants.INPUT, selectOne);
writer.writeAttribute(HtmlAttributes.TYPE, "radio", false);
writer.writeClassAttribute();
boolean checked = item.getValue().equals(value);
if (checked) {
writer.writeAttribute(HtmlAttributes.CHECKED, "checked", false);
}
writer.writeNameAttribute(clientId);
writer.writeIdAttribute(id);
String formattedValue = RenderUtil.getFormattedValue(facesContext, selectOne, item.getValue());
writer.writeAttribute(HtmlAttributes.VALUE, formattedValue, true);
writer.writeAttribute(HtmlAttributes.DISABLED, item.isDisabled() || disabled);
if (readonly) {
writer.writeAttribute(HtmlAttributes.READONLY, true);
}
Integer tabIndex = selectOne.getTabIndex();
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
HtmlRendererUtil.renderTip(selectOne, writer);
if (!ComponentUtil.getBooleanAttribute(selectOne, ATTR_REQUIRED) || readonly) {