ComponentUtils.addCurrentMarkup(select, Markup.INLINE);
}
}
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
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();
boolean required = select.isRequired();
Style style = new Style(facesContext, select);
// fixme: use CSS, not the Style Attribute for "display"
style.setDisplay(null);
writer.startElement(HtmlElements.OL, select);
writer.writeIdAttribute(id);
writer.writeStyleAttribute(style);
writer.writeClassAttribute(Classes.create(select));
HtmlRendererUtils.writeDataAttributes(facesContext, writer, select);
if (title != null) {
writer.writeAttribute(HtmlAttributes.TITLE, title, true);
}
boolean first = true;
Object[] values = select.getSelectedValues();
for (SelectItem item : items) {
String itemId = id + NamingContainer.SEPARATOR_CHAR + NamingContainer.SEPARATOR_CHAR + item.getValue().toString();
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);
writer.writeAttribute(HtmlAttributes.REQUIRED, required);
if (first) {
HtmlRendererUtils.renderFocus(id, select.isFocus(), ComponentUtils.isError(select), facesContext, writer);
first = false;
}
Integer tabIndex = select.getTabIndex();
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
HtmlRendererUtils.renderCommandFacet(select, itemId, facesContext, writer);
writer.endElement(HtmlElements.INPUT);