AbstractSelect.NewItemHandler validation

Is it possible for a newItemHandler to generate a validation error/exception that is displayed as an error by the underlying UI component (ComboBox in my case)?

e.g. can the newItemHandler in Book of Vaadin section 5.5.6, raise a “This is not a planet” validation error if the user tries to enter “Pluto”?

Would something like

if (!validPlanetNames.contains(newItemCaption)) { throw new InvalidValueException("This is not a planet"); } at the beginning of your NewItemHandler’s addNewItem(String newItemCaption) method work for your needs? The correct import for that would be

import com.vaadin.data.Validator.InvalidValueException; And you’d of course need to create that list of valid names as well.

Thanks, that works as expected.