wicket-select2
wicket-select2 copied to clipboard
Any way to be notified of selected choices?
Igor - is there any way to be notified via a callback of a user selection in a Select2MultiChoice?
Ive got the component hooked up and working fine, complete with search function, but Im trying to sync the selected items in the MultiChoice after each user selection - is this possible?
No problem, simply do something like this:
Select2MultiChoice<String> multiChoice = new Select2MultiChoice<String>(
"multiChoice", model, choiceProvider);
form.add(multiChoice);
multiChoice.add(new AjaxEventBehavior("change")
{
@Override
protected void onEvent(AjaxRequestTarget target)
{
// do something useful here
}
});
Ah ok, if you'd like to sync on each change then you better do something like this:
multiChoice.add(new AjaxFormSubmitBehavior(form, "change")
{
@Override
protected void onSubmit(AjaxRequestTarget target)
{
// do something useful here
}
});
Thanks Tom! Will this submit the whole form or just the items in the MultiChoice?
This will submit the whole form. If you just want to submit the values of the MultiChoice, try org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior.
I already tried that using: emailsMC.add( new AjaxFormComponentUpdatingBehavior( "change" ){...}
The IModel isnt being updated as expected - hence this question :-)
Just tried AjaxFormComponentUpdatingBehavior in a quickstart and it works fine for me ...