P: selectCheckboxMenu 'Select all' ajax listener not being called

I have JSF: Primefaces SelectCheckBoxMenu

<p:selectCheckboxMenu value="#{domain.listaa}" label="Chooese!" style="height:25px" showCheckbox="true"> <p:ajax update="records" listener="#{domain.muti}" /> <f:selectItems value="#{domain.recLabels}"/> </p:selectCheckboxMenu> 

In managed beans:

 private boolean[] recFlags = new boolean[]{true,true,true,true,true,true,true}; private String[] recLabels = new String[]{"A","AAAA","MX","NS","SOA","CNAME","TXT"}; private List<String> listaa = new ArrayList<>(); public void muti(AjaxBehaviorEvent event){ Arrays.fill(recFlags, false); for(int i=0;i<recLabels.length;i++){ if(listaa.contains(recLabels[i])){ recFlags[i]=true; } } System.out.println(listaa.toString()); } 

So, in SelectCheckBoxMenu I press any button, the ajax call works and the muti () function starts. No problems. But if I click the "select all" button (most of the above) in SelectCheckboxMenu, the ajax call will not work, the muti () function will not be launched, and the list (list of checked flags) will not change. What for? How can I decide that the Select All button works?

+6
source share
3 answers

Primefaces 4 and 5 have a special ajax event for the Toggle All checkbox - toggleSelect .

Just add it with the same attributes as the default ajax event.

 <p:selectCheckboxMenu value="#{domain.listaa}" label="Chooese!" style="height:25px" showCheckbox="true"> <p:ajax update="records" listener="#{domain.muti}" /> <p:ajax event="toggleSelect" update="records" listener="#{domain.muti}" /> <f:selectItems value="#{domain.recLabels}"/> </p:selectCheckboxMenu> 
+13
source

It works.

 <p:ajax event="toggleSelect" process="@this" partialSubmit="true" /> 
+1
source

All Articles