I have a checkbox in a column of a "p: dataTable" and I have a button that I want to paint only if I have a row checked. (I do not use selectionMode = "multiple", because not all my rows have the checkbox, only some)
// column table
<p:column>
<p:selectBooleanCheckbox
rendered="#{item.esBorrable}"
valueChangeListener="#{candidatoController.checkCandidatoGdprBorrable}"
value="#{item.borrar}">
<p:ajax
event="change"
process="@form"
update="@(.button-asociar-chequeados)" />
</p:selectBooleanCheckbox>
</p:column>
// controller
public void checkCandidatoGdprBorrable(ValueChangeEvent event) {
listCandidatoGdprDto.setHayCandidatosBorrables(false);
@SuppressWarnings("unchecked")
List<CandidatoGdpr> candidatos = (List<CandidatoGdpr>) listCandidatoGdprDto.getDataModel().getWrappedData();
for (CandidatoGdpr candidatoGdpr : candidatos) {
if (candidatoGdpr.getBorrar()) {
listCandidatoGdprDto.setHayCandidatosBorrables(true);
}
}
}
// buttom
<p:outputPanel styleClass="button-asociar-chequeados">
<p:commandButton
value="Borrar chequeados"
icon="aba-icon ss_arrow_in"
rendered="#{listCandidatoGdprDto.hayCandidatosBorrables}"
onclick="PF('deleteCandidatoGdprConfirmDialogWidget').show();"
title="Borrar chequeados a la petición" />
The code goes well, but it goes with a click of delay, until I select two chech of two rows no moe paints the button.