Wicket: can Checkgroup be Ajax enabled?

2019-08-09 11:20发布

问题:

I have a dynamic list of choices, each represented by a checkbox. I also have a "select all" check box that selects them all. i am using a CheckGoup, 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 some of the checkboxes are selected.

I thought the simpliest is to Ajax-enable the Check but it seems its not possible. seems that Check does not allow you to add a AjaxFormComponentUpdatingBehavior to it.

is there any simple way to achieve this?

I was also thinking of using plain o'ld checkboxes and add javascript to do the select all. At least the checkbox can be ajax-enabled.

thoughts?

回答1:

The easiest would be to replace the CheckBoxes by AjaxCheckboxes since The CheckGroupSelector triggers the onClick event of each associated Checkbox, thus triggering the Ajax-part oft he AjaxCheckbox. As far as I know (and as far as the Javadoc states), the CheckGroupSelector runs on the client-side in JavaScript so this should work.