title: Ajax in JSF with selectManyCheckbox
body: <p>I have a datatable and two checkboxes. The content of the datatable is rendered considering which of the checkboxes are selected. I have the following functional code which renders the datable content when pressing the submit button:</p>
  
  <pre><code>&lt;h:form&gt; 
              &lt;h:selectManyCheckbox value="#{myBean.selections}"&gt;
                  &lt;f:selectItem itemValue="expired" itemLabel="Expired" /&gt;
                  &lt;f:selectItem itemValue="active" itemLabel="Active" /&gt;                  
              &lt;/h:selectManyCheckbox&gt;
              &lt;h:commandButton id="submit" value="Select"
                  action="#{myBean.getList}" /&gt; 
  &lt;/h:form&gt;
  
  &lt;h:form&gt;
              &lt;h:dataTable ... /&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>However, I want to replace the submit button with an ajax call using the f:ajax tag. I tried something like:</p>
  
  <pre><code>&lt;h:selectManyCheckbox value="#{myBean.selections}"&gt;
                  &lt;f:selectItem itemValue="expired" itemLabel="Expired" /&gt;
                  &lt;f:selectItem itemValue="active" itemLabel="Active" /&gt;                  
                  &lt;f:ajax event="click" render="@form" listener="#{myBean.getList}" /&gt;
  &lt;/h:selectManyCheckbox&gt;
  &lt;h:form&gt;
      &lt;h:dataTable .... /&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>But the content is not rendered. What am I doing wrong?</p>
  
  <p>Bean:</p>
  
  <pre><code>    public String[] selections = { "expired", "active" };
  
  public String[] getSelections() {
      return selections;
  }
  
  public void setSelections(String[] selections) {
      this.selections = selections;
  }
  
  public void getList() {
      for (String option : selections) {
          // add expired
          if (option.equals("expired"))
              showExpired();
          // add active 
          else if (option.equals("active"))
              showActive();
      }
       //return Arrays.toString(selections);
  }
  </code></pre>