JSF ValueChangeListener on checkbox misfiring?
843844Mar 25 2009 — edited Mar 27 2009I am assuming the value change listener is not misfiring, but I have searched the Net on this one with no luck and can't guess what I'm doing wrong here:
I have a a checkbox with a valueChangeListener:
<h:selectBooleanCheckbox
onclick="submit()"
immediate="true"
valueChangeListener="#{CategoryFormBackingBean.forRecurringBillOnChange}"
id="forRecurringBill"
value="#{Category.forRecurringBill}"/>
When I:
1. Load up the form for the first time ( and this only happens on the first load of the form)
2. If #{Category.forRecurringBill} happens to evaluate to true and the checkbox is initially checked, the first time I try to submit the form by clicking the "Submit" commandButton
Even though the checkbox rendered as "checked" when the form loaded, and I didn't touch the checkbox before clicking the "Submit" button, instead of going to the Action Method for the "Submit" commandButton, the valueChangeListener for the checkbox is instead called?!
This problem only happens on the first load of the form, and only if the checkbox is checked as true on that first load. If the checkbox is checked as false on that first load, the form dispatches as expected when I click the "Submit" button.
I am using Sun's JSF 1.2 RI if it helps?
As extra info, this checkbox is used to toggle the visibility of part of the form when it is checked/unchecked. So when a user checks it it triggers a Javascript submit of the form, and I am using immediate=true to bipass validation while re-rendering the form. I don't know if having immediate=true on the checkbox is affecting something?
I'm posting a lot to this forum on JSF - hopefully not spamming the forum here :( Again, just if someone has time I'd really appreciate it!,
Jim