Skip to content

Instantly share code, notes, and snippets.

@hatemalimam
Created June 30, 2017 09:11
Show Gist options
  • Save hatemalimam/6a2d04d49afb36d3eb5a2bfd856c8d2d to your computer and use it in GitHub Desktop.
Save hatemalimam/6a2d04d49afb36d3eb5a2bfd856c8d2d to your computer and use it in GitHub Desktop.
<p:selectBooleanCheckbox itemLabel="Check All"
widgetVar="checkAllWV"
onchange="selectAllCheckBoxes(PF('checkAllWV'),PF('manyCheckWV'))">
</p:selectBooleanCheckbox>
<p:selectManyCheckbox widgetVar="manyCheckWV">
<f:selectItems value="#{mainBean.list}"/>
</p:selectManyCheckbox>
<script>
function selectAllCheckBoxes(selectAllCheckbox, manyCheckBoxes) {
manyCheckBoxes.inputs.each(function() {
if(selectAllCheckbox.isChecked()) {
$(this).prop('checked', false)
selectAllCheckbox.jq.find('.ui-chkbox-label').text('Uncheck all')
} else {
$(this).prop('checked', true)
selectAllCheckbox.jq.find('.ui-chkbox-label').text('Check all')
}
$(this).trigger('click');
})
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment