I'm trying to do some action in the ManagedBean based on the state of the checkbox.
Checkbox is here:
<p:selectBooleanCheckbox id="cb">
<p:ajax listener="#{myBB.checkboxChanged}"/>
</p:selectBooleanCheckbox>
The signature of the listener method is this:
public void checkboxChanged(AjaxBehaviorEvent event)
The listener method is called as expected, but I'm not sure how to get the state of the checkbox(if it is selected) This is false all the time:
((SelectBooleanCheckbox)event.getSource()).isSelected()
Do I need to bind the value of the checkbox? I'd like to avoid that, because the checkboxes are generated from enum in a loop and I don't have any boolean where to bind it(the model is designed in a way that I'm adding/removing the instances of enum to a collection, not setting boolean properties)
I'm running the code on Tomcat 6.0.36 with Primefaces 3.5
JSF implementation is Apache Myfaces 2.1.10
Your code works as expected for me on Mojarra 2.2.1 and PrimeFaces 4.0RC1 as well as Mojarra 2.0.3 and PrimeFaces 3.5. Unfortunately I didn't have 2.1 handy. What version of PrimeFaces are you using? Can you post your complete code?