简体   繁体   English

选中“全部检查”复选框不会调用p:ajax标签JSF

[英]Checking 'check all' checkbox doesn't call p:ajax tag JSF

ajax doesn't work when I check 'check all box' checkbox. 当我选中“选中所有复选框”复选框时,ajax无法正常工作。

 <p:selectCheckboxMenu id="departmantCheckBox" value="#{marketAnalysisReportController.selectedDepartmants}"  filter="true" filterMatchMode="startsWith" panelStyle="width:250px">
            <p:ajax update="saleCheckBox" listener="#{marketAnalysisReportController.updateSales}"/>
            <f:selectItems value="#{marketAnalysisReportController.departmants}" var="departmant"
                            itemValue="#{departmant}"
                            itemLabel="#{departmant.name}"/>
        </p:selectCheckboxMenu>

Here's update method 这是更新方法

public void updateSales(){
        sales=new ArrayList<Obje>();
        System.out.println("updatesales");
        for(Obje departmant: selectedDepartmants){
            System.out.println(departmant.name);
            if(departmant.getName().equals("test1")){
                sales.add(new Obje(20,"salestest20"));
                sales.add(new Obje(21,"salestest21"));
                System.out.println("add");
            }
            if(departmant.getName().equals("test2")){
                sales.add(new Obje(200,"salestest200"));
                sales.add(new Obje(210,"salestest210"));
            }
            if(departmant.getName().equals("test3")){
                sales.add(new Obje(250,"salestest250"));
                sales.add(new Obje(260,"salestest260"));
            }
            if(departmant==null || departmant.equals("")){
                sales=new ArrayList<Obje>();
            }
        }
    }

If I check boxes one by one, it works, but when I check 'check all checkboxes' it doesn't update sales. 如果我一个接一个地选中复选框,则可以使用,但是当我选中“选中所有复选框”时,则不会更新销售。 I can share more detail if you need. 如果您需要,我可以分享更多细节。

As Kukeltje allready pointed out the 'select all'- action does not fire the default ajax event which is caught by your tag. 正如Kukeltje早已指出的那样,“全选”操作不会触发您的代码捕获的默认ajax事件。 The ajax event that is being fired when you select all is called 'toggleSelect', so you need to add another ajax tag like this: 当您全选时触发的ajax事件称为“ toggleSelect”,因此您需要添加另一个ajax标签,如下所示:

< p:ajax event="toggleSelect"... <p:ajax event =“ toggleSelect” ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM