wicket-select2
wicket-select2 copied to clipboard
Select2 expects provider to always give an answer
The Select2Choice class in the convertInput method expects the provider to give an answer given an input on line 54:
setConvertedInput(getProvider().toChoices(Collections.singleton(input)).iterator().next());
If you update the contents of the Select2 via Ajax and the backing model has updated but the front end has not, it can be possible for the Select2 to send a meaningless input to the server. The provider getProvider() is expected to always return an option server side, while the input might not have made sense.
Instead of calling iterator().next() it should check if there is indeed an answer, if the backing provider finds the input valid.