SelectBooleanCheckbox in editable DataTable doesn't change
This is a bug, or at least an oversight, in PrimeFaces.
According to the JavaScript code involved (saveCell()
function in datatable.js
), it only compares the input's new value with the old value before submitting the new value to the server, like so if (input.value != oldvalue)
. However, in case of checkboxes (and radio buttons) the input value is never changed. It's always the same. It's only the checked state which should trigger the browser to actually send the state to the server or not.
In other words, the JavaScript code involved should have checked if it's a checkbox (or radiobutton) and then check by if (input.checked != oldchecked)
instead.
There's no way to fix it other than editing the primefaces.js
/datatable.js
. You'd best report this issue to PrimeFaces guys and get them to fix it.
In the meanwhile, you can workaround it by copying the value to a hidden input field.
<f:facet name="input">
<h:inputHidden value="#{submodel.mapping}" />
<h:selectBooleanCheckbox value="#{submodel.mapping}" onclick="$(this).prev().val(this.checked)" />
</f:facet>