I have a problem similar to this question: Wicket: can Checkgroup be Ajax enabled?
I’m using a ListView where each Item has a checkbox. I also have a “select all” checkbox. I am using a CheckGroup, CheckGroupSelector and Check and everything works great. Now there is a new requirement to change the state on some other controls on the page when the checkboxes are updated.
Nicktar’s suggestion in the above linked question was the first that came to my mind, too, but I haven’t been able to find out how it is possible to use AjaxCheckBox with CheckGroup/CheckGroupSelector. According to the doc you have to use Check.
But in this mail from 2008, Igor Vaynberg also states that it is possible to use AjaxCheckBox in a CheckGroup.
I tried it with just replacing where I used Check with the AjaxCheckBox, but it didn’t work, the CheckGroupSelector didn’t find the checkboxes anymore.
I also looked into using the onSelectionChanged method in CheckGroup, but I’d like to avoid using this as it triggers another roundtrip to the server, as far as I understood.
Can someone give me a hint? Or is there another nice solution for this?
By the way, I’m using Wicket 1.4.
Why can’t you add an
AjaxFormChoiceComponentUpdatingBehaviorto theCheckGroup?From
AjaxFormComponentUpdatingBehavior‘s JavaDoc:AjaxFormChoiceComponentUpdatingBehavioris the behavior to use withCheckGroups andRadioGroups. If you used anAjaxFormComponentUpdatingBehaviorwith theonchangeevent, you’d run into this bug with IE.
AjaxFormChoiceComponentUpdatingBehaviorhandles this properly, addingonclickevent handlers to each of theChecks in theCheckGroup.As a side note, what Igor stated in that mail, is that
CheckBoxcan be replaced withAjaxCheckBox, notCheck.AjaxCheckBoxis nothing more than a convenience subclass ofCheckBoxwith anAjaxFormComponentUpdatingBehavior("onclick"), as the sources show.