简体   繁体   English

如何在质数中选择所有复选框

[英]How to selectall checboxes in primefaces selectManyCheckbox

I want to write a code where on selection of one checkbox all other checkboxes grouped under selectManycheckbox are also selected. 我想编写一个代码,其中选中一个复选框时,还选中了selectManycheckbox下分组的所有其他复选框。

<p:selectManyCheckbox id="inputSelectManyCheckbox" value="#{valueList}"  
valueChangeListener="#{valueChangeMethod}" label="#{label}">
              <p:ajax listener="#{actionListener}" />
 </p:selectManyCheckbox>

Try this: 尝试这个:

<p:selectBooleanCheckbox value="#{...}">
  <p:ajax event="change" 
          listener="yourBean.checkAll()" 
          update="inputSelectManyCheckbox" />
</p:selectBooleanCheckbox>

... and ... ...和...

@ManagedBean
@....Scoped
public class YourBean {
  public void checkAll(){
    for(Boolean b : this.getValueList()){
      b = true;
    }
  }
}

Please note: the value of a p:selectManyCheckbox is a list of only the selected items! 请注意: p:selectManyCheckbox的值仅是所选项目的列表! I hope you can adapt my example to your code! 希望您可以将我的示例适应您的代码!

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

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