LOG.error("Wrong type: Need " + UISelectManyCheckbox.class.getName() + ", but was "
+ component.getClass().getName());
return;
}
UISelectManyCheckbox select = (UISelectManyCheckbox) component;
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
String id = select.getClientId(facesContext);
List<SelectItem> items = RenderUtils.getItemsToRender(select);
String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
boolean disabled = select.isDisabled();
boolean readonly = select.isReadonly();
Style style = new Style(facesContext, select);
// fixme: use CSS, not the Style Attribute for "display"
style.setDisplay(null);
writer.startElement(HtmlElements.OL, select);
writer.writeStyleAttribute(style);
writer.writeClassAttribute(Classes.create(select));
if (title != null) {
writer.writeAttribute(HtmlAttributes.TITLE, title, true);
}
Object[] values = select.getSelectedValues();
List<String> clientIds = new ArrayList<String>();
for (SelectItem item : items) {
String itemId = id + NamingContainer.SEPARATOR_CHAR + NamingContainer.SEPARATOR_CHAR + item.getValue().toString();
clientIds.add(itemId);
writer.startElement(HtmlElements.LI, select);
writer.startElement(HtmlElements.INPUT, select);
writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.CHECKBOX, false);
boolean checked = RenderUtils.contains(values, item.getValue());
writer.writeAttribute(HtmlAttributes.CHECKED, checked);
writer.writeNameAttribute(id);
writer.writeIdAttribute(itemId);
String formattedValue = RenderUtils.getFormattedValue(facesContext, select, item.getValue());
writer.writeAttribute(HtmlAttributes.VALUE, formattedValue, true);
writer.writeAttribute(HtmlAttributes.DISABLED, item.isDisabled() || disabled);
writer.writeAttribute(HtmlAttributes.READONLY, readonly);
if (readonly) {
writer.writeAttribute(HtmlAttributes.ONCLICK, "this.checked=" + checked, false);
}
Integer tabIndex = select.getTabIndex();
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
writer.endElement(HtmlElements.INPUT);