Wicket: (how) can I associate an AjaxCheckBox with a CheckGroupSelector?

I have a problem similar to this question: Wicket: Can Ajax be enabled for Checkgroup?

I use ListView where each item has a checkbox. I also have a Select All checkbox. I use CheckGroup , CheckGroupSelector and Check , and everything works fine. Now there is a new requirement to change state on some other controls on the page when updating flags.

Nicktar's suggestion in the above related question was the first thing that occurred to me, but I was not able to find out how to use AjaxCheckBox with CheckGroup / CheckGroupSelector . According to the document, you should use Check .

But in this letter since 2008 , Igor Weinberg also states that you can use AjaxCheckBox in CheckGroup .

I tried this by simply replacing where I used Check with AjaxCheckBox , but it didnโ€™t work, CheckGroupSelector no longer found these checkboxes.

I also studied the use of the onSelectionChanged method in CheckGroup , but I would like to avoid using this, as it, as I understand it, starts another server to switch to another server.

Can someone tell me? Or is there another good solution for this?

By the way, I am using Wicket 1.4.

+4
source share
1 answer

Why can't you add AjaxFormChoiceComponentUpdatingBehavior to CheckGroup ?

From AjaxFormComponentUpdatingBehavior JavaDoc:

NOTE. This behavior does not work on selections or groups, for which AjaxFormChoiceComponentUpdatingBehavior is used.

AjaxFormChoiceComponentUpdatingBehavior is the behavior that should be used with CheckGroup and RadioGroup s. If you used AjaxFormComponentUpdatingBehavior with the AjaxFormComponentUpdatingBehavior event, you would encounter this error with IE, AjaxFormChoiceComponentUpdatingBehavior handles this correctly, adds onclick event handlers to each of the Check in CheckGroup .

As a note that Igor said in this post is that CheckBox can be replaced with AjaxCheckBox , not Check . AjaxCheckBox is nothing more than a convenient subclass of CheckBox with AjaxFormComponentUpdatingBehavior("onclick") , as it shows the sources .

+2
source

Source: https://habr.com/ru/post/1382692/


All Articles