1

I want to write a code where on selection of one checkbox all other checkboxes grouped under selectManycheckbox are also selected.

<p:selectManyCheckbox id="inputSelectManyCheckbox" value="#{valueList}"  
valueChangeListener="#{valueChangeMethod}" label="#{label}">
              <p:ajax listener="#{actionListener}" />
 </p:selectManyCheckbox>
Qasim Ali
  • 107
  • 1
  • 7
  • 2
    possible duplicate of [check f:items value based on p:selectManyCheckbox using javascript](http://stackoverflow.com/questions/25970385/check-fitems-value-based-on-pselectmanycheckbox-using-javascript) – Hatem Alimam Nov 28 '14 at 13:58
  • Thanks Hatem, that means only way to do it is via javascript? – Qasim Ali Nov 28 '14 at 14:27
  • You can do it in the backend, but for me it's not meant to be in the backend, it's more likely a client-side function. – Hatem Alimam Nov 28 '14 at 14:31

1 Answers1

0

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! I hope you can adapt my example to your code!

Dawn
  • 126
  • 6