if (!(component instanceof UISelectMany)) {
LOG.error("Wrong type: Need " + UISelectMany.class.getName() + ", but was " + component.getClass().getName());
return;
}
UISelectMany selectMany = (UISelectMany) component;
List<SelectItem> items = ComponentUtil.getItemsToRender(selectMany);
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
Object[] values = selectMany.getSelectedValues();
if (LOG.isDebugEnabled()) {
LOG.debug("values = '" + Arrays.toString(values) + "'");
}
String id = selectMany.getClientId(facesContext);
boolean inline = ComponentUtil.getBooleanAttribute(selectMany, ATTR_INLINE);
String title = HtmlRendererUtil.getTitleFromTipAndMessages(facesContext, selectMany);
if (!inline) {
writer.startElement(HtmlConstants.TABLE, selectMany);
// 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);
}
}
List<String> clientIds = new ArrayList<String>();
for (SelectItem item : items) {
if (!inline) {
writer.startElement(HtmlConstants.TR, null);
writer.startElement(HtmlConstants.TD, null);
}
String itemId = id
+ NamingContainer.SEPARATOR_CHAR + NamingContainer.SEPARATOR_CHAR
+ item.getValue().toString();
clientIds.add(itemId);
writer.startElement(HtmlConstants.INPUT, selectMany);
writer.writeAttribute(HtmlAttributes.TYPE, "checkbox", false);
writer.writeClassAttribute();
writer.writeAttribute(HtmlAttributes.CHECKED, RenderUtil.contains(values, item.getValue()));
writer.writeNameAttribute(id);
writer.writeIdAttribute(itemId);
String formattedValue = RenderUtil.getFormattedValue(facesContext, selectMany, item.getValue());
writer.writeAttribute(HtmlAttributes.VALUE, formattedValue, true);
writer.writeAttribute(HtmlAttributes.DISABLED, item.isDisabled());
Integer tabIndex = selectMany.getTabIndex();
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
writer.endElement(HtmlConstants.INPUT);