I have a 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 the 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 the SelectCheckBoxMenu I press any button, the ajax call is working, and the muti() function will run. There is no problem. But if I press the 'select all' (most above) button in the SelectCheckboxMenu, the ajax call is not working, muti() function won't run and the listaa (List about the pressed checkboxs) is not changing. Why? How can I solve, that 'select all' button works?
In Primefaces 4 and 5 there is a special ajax event for 'Toggle all' checkbox - toggleSelect.
Just add it with the same attributes as your 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>
This works.
<p:ajax event="toggleSelect" process="@this" partialSubmit="true" />
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