webtier@glassfish.java.net

Attach a JSF 2 AJAX Tag to a HtmlSelectManyCheckbox

From: <webtier_at_javadesktop.org>
Date: Wed, 31 Mar 2010 07:08:58 PDT

I've been trying to attach an AJAX tag to a selectManyCheckbox component and I am not having the best of luck.

[b]Template[/b]:
<h:form id="myForm" prependId="false">
  <h:selectManyCheckbox id="testList" binding="#{testController.testListInput}">
    <f:ajax event="click" render="foo" listener="#{testController.updateFoo}" execute="@this" />
    <f:selectItems value="#{testController.getSelectItems}" var="item" label="item.value" />
  </h:selectManyCheckbox>

  <h:outputText id="foo" value="#{testController.count}" />
</h:form>

[b]Backing Bean[/b]:
public class TestController {
  private HtmlSelectManyCheckbox testListInput;
  private Integer count = 0;

  public Integer getCount() {
    return count;
  }

  public void updateFoo(AjaxBehaviorEvent e) {
    count++;
  }
  
  public HtmlSelectManyCheckbox getTestListInput() {
    return testListInput;
  }

  public void setTestListInput(HtmlSelectManyCheckbox i) {
    this.testListInput = i;
  }
  ...
}

When my html is rendered and I click on the check boxes they turn gray and don't stay selected or checked, but when I refresh the page they are selected. No AJAX behavior event occurs either when the checkboxes are clicked.

Thanks,
Derek
[Message sent by forum member 'dperriero']

http://forums.java.net/jive/thread.jspa?messageID=394645