JSF 2 valuechangeListener on checkbox works only for uncheck

Sanath picture Sanath · Jun 23, 2011 · Viewed 7.6k times · Source
<a4j:ajax render="tree">
<h:selectBooleanCheckbox id="checkEntry" value="#{bean.selected}" immediate="true"  disabled="false" valueChangeListener="#{bean.changeActive}"/>
  </a4j:ajax>

My checkbox for JSF is triggering the event "bean.changeActive", when I uncheck my checkbox..but when rechecking it, it doesn't trigger The form tag is properly used.. any help on this regard is appreciated..

Answer

BalusC picture BalusC · Jun 23, 2011

You're actually not interested in the value change event. You are interested in the click event. The checkbox value remains the same. It's only the checked state which changes. It's the checked state which controls whether the value will be sent or not.

Use the click event instead and attach a listener on it.

<a4j:ajax event="click" listener="#{bean.changeActive}" render="tree">