I need to execute a backing bean method when the user selects that checkbox on the top (the one that selects all the check-boxes).
I'm talking about this one:
As for the regular check boxes:
I was able to execute a backing bean method by adding the following tags inside the <p:dataTable><p:dataTable/>
:
<p:ajax event="rowSelectCheckbox" listener="#{beanJanela.atualizaVariacaoSaldo}" update="variacaoSaldo" />
<p:ajax event="rowUnselectCheckbox" listener="#{beanJanela.atualizaVariacaoSaldo}" update="variacaoSaldo" />
It almost seems like it would be a matter of just adding another <p:ajax .. />
with an event like rowSelectAllCheckbox
, unfortunately that event does not exist.
So how would I go about executing #{beanJanela.atualizaVariacaoSaldo}
when that first checkbox is selected? Thank you.
The Primefaces User Guide (Version 6.2), page 181 offers the following event on p:datatable:
Event: toggleSelect
Listener Parameter: org.primefaces.event.ToggleSelectEvent
Fired: When header checkbox is toggled.
So try using
<p:ajax event="toggleSelect" .../>
on the datatable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With