title: JSF 2 check / uncheck list of h:selectBooleanCheckbox
body: <p>I have a loop with a bunch of h:selectBooleanCheckboxs inside a ui:repeat and I want to be able to check / uncheck all of them with one click. Following <a href="https://stackoverflow.com/questions/2929037/select-and-unselect-list-of-checkboxes-with-single-checkbox">this</a> this is how I try to do it: </p>
  
  <pre><code>&lt;h:selectBooleanCheckbox value="#{bean.selectAll}" valueChangeListener="#{bean.selectAllCustomers}"&gt;
      &lt;f:ajax execute="@form" render="entireLoop"/&gt;
  &lt;/h:selectBooleanCheckbox&gt;
  </code></pre>
  
  <p>The loop: </p>
  
  <pre><code>&lt;h:panelGroup id="entireLoop"&gt;  
    &lt;ui:repeat var="customer" varStatus="status" value="#{bean.customers}"&gt;
  
      &lt;tr&gt; 
          &lt;td&gt;
      &lt;h:selectBooleanCheckbox value="#{bean.customersMap[customer]}"/&gt;
          &lt;/td&gt;
        &lt;td&gt;&lt;h:commandLink value="#{customer.userID}" action="#{navBean.gotoEditCustomer(customer)}"/&gt;&lt;/td&gt;
        &lt;td&gt;#{bean.getContact(user)}&lt;/td&gt;
        &lt;td&gt;#{customer.companyName}&lt;/td&gt;
        &lt;td&gt;#{customer.email}&lt;/td&gt;
        &lt;td&gt;#{customer.phone}&lt;/td&gt;
      &lt;/tr&gt;       
    &lt;/ui:repeat&gt;  
  &lt;/h:panelGroup&gt;
  </code></pre>
  
  <p>The code in the bean: </p>
  
  <pre><code>public void selectAllCustomers() {
      Iterator&lt;User&gt; keys = customersMap.keySet().iterator();
      while(keys.hasNext()) {
          User user = keys.next();
          customersMap.put(user, selectAll);
      }
  }
  </code></pre>
  
  <p>When I click to check the "select all" checkbox, I have two problems: </p>
  
  <ol>
  <li><p>Nothing happens. Only when I click on somewhere else in the page the method is called. How can I get it to go directly?</p></li>
  <li><p>The entire loop disappears from the page. Why? (I tried to get the ajax to render only the selectBooleanCheckbox by giving it an id, or a name, but I'm getting an error saying this is not a naming component.)</p></li>
  </ol>