With JSF 1.x, there are two ways to achieve this.
Submit the form to the onclick server of this check box.
<t:selectBooleanCheckbox value="#{bean.selectAll}" onclick="submit()" />
And just follow the logic of selecting / deselecting all the checkboxes.
public void submit() {
for (CheckboxItem item : checkboxItems) {
item.setSelected(selectAll);
}
}
: . - , , . JSF, .
JavaScript, .
<t:selectBooleanCheckbox value="#{bean.selectAll}" onclick="selectAll(this)" />
function selectAll(checkbox) {
var elements = checkbox.form.elements;
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (/checkboxId$/.test(element.id)) {
element.checked = checkbox.checked;
}
}
}
, , , , checkboxId. HTML, . , , , .
, , " ", .
JSF 2.x , , <f:ajax> onclick.