wicket-select2 icon indicating copy to clipboard operation
wicket-select2 copied to clipboard

Select2 expects provider to always give an answer

Open Stijnvdk opened this issue 10 years ago • 0 comments

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.

Stijnvdk avatar Nov 10 '14 14:11 Stijnvdk