Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p:selectCheckboxMenu 'Select all' ajax listener not invoked

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?

like image 703
user2693979 Avatar asked Apr 27 '14 11:04

user2693979


Video Answer


2 Answers

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>
like image 152
BlindNW Avatar answered Sep 17 '22 15:09

BlindNW


This works.

<p:ajax event="toggleSelect"  process="@this" partialSubmit="true" />
like image 42
Paul Volkov Avatar answered Sep 19 '22 15:09

Paul Volkov