Reputation: 9586
I'm using Wicket 6.20.0's CheckBoxMultipleChoice
and leveraging AJAX functionality by adding a AjaxFormChoiceComponentUpdatingBehavior
.
This is working as required. However, using WicketTester
to test the functionality of CheckBoxMultipleChoice
seems impossible.
When I use WicketTester
's debugComponentTrees()
the only path for the CheckBoxMultipleChoice
is its direct path, I.E. there are no child CheckBox
objects or similar I can obtain to execute AJAX events on.
How can I execute an AJAX event, such as clicking one of the check boxes, using WicketTester
?
Upvotes: 0
Views: 834
Reputation: 17513
CheckBoxMultipleChoice is an "optimized" form component, i.e. it uses String concatenation to create its "children" - the check boxes. If it was using CheckBox components then it would lead to bigger component tree and more memory consumption.
To test it with WicketTester you just need to set the request parameter with all selected values:
tester.getRequest().addParameter(cbmc.getInputName(), "value1");
tester.getRequest().addParameter(cbmc.getInputName(), "value2");
// ...
tester.executeAjaxEvent(cbmc, "click");
// assert
Upvotes: 2