validateParameters(context, component);
AllRowsSelectorComponent allRowsSelector = (AllRowsSelectorComponent) component;
UIData data = getTargetUIData(allRowsSelector);
RowSelectorComponent rowSelector = getRowSelector(data);
if (rowSelector.getMode() != RowSelectorComponent.Mode.multi) {
log.error("An allRowsSelector component was specified for dataTable component " + data
+ ", which has a rowSelector with mode 'single', "
+ "but allRowsSelector components can only be used with rowSelectors with mode 'multi'. "
+ "The allRowSelector will not be rendered.");
allRowsSelector.setRendered(false);
return;
}
// TODO: Do not render if the data model's row count is 0.
ResponseWriter writer = context.getResponseWriter();
writer.startElement("input", component);
writeIdAttributeIfNecessary(context, writer, component);
String type = "checkbox";
writer.writeAttribute("type", type, "type");
String clientId = component.getClientId(context);
writer.writeAttribute("name", clientId, "clientId");
// TODO: Write 'checked' attribute to allow checkbox to be selected by default? Probably overkill.
String onclick = "selectAll(this, '" + rowSelector.getClientId(context) + "')";
String userSpecifiedOnclick = (String) rowSelector.getAttributes().get("onclick");
if (userSpecifiedOnclick != null) {
onclick += "; " + userSpecifiedOnclick;
}
writer.writeAttribute("onclick", onclick, "onclick");
// TODO: Add support for all the other common HTML attributes.
//RenderKitUtils.renderPassThruAttributes(writer, component, ATTRIBUTES);
Boolean disabled = (Boolean) rowSelector.getAttributes().get("disabled");
if (disabled != null && disabled) {
writer.writeAttribute("disabled", "disabled", "disabled");
}
//RenderKitUtils.renderXHTMLStyleBooleanAttributes(writer, component);