user4375474
user4375474

Reputation:

Vaadin Combobox - New Item

I am writing Code in Java and I am using the Vaadin 8 extension.

I have a Vaadin Combo Box and it works well. But I would like to not only select items from my Combo Box, but also select the written input. That means I would like to use the Combo Box as a Drop Down Menu and also as an Text Edit Field.

After some research I think it is not possible to get the value of the Combo Box after writing something into it. The Text Edit Field is only for searching in the Drop Down Menu. If I type something that is not part of the Drop Down Menu the value is null.

But it seems possible to add new Items to the Combo Box Drop Down Menu with the method setNewItemProvider.

There are some examples out there that use the old method getNewItemHandler but they dont seem to work for the newest Vaadin version 8. The method setNewItemsAllowed is no longer part of Vaadin 8.

Can anyone provide an example with the new method setNewItemProvider for Vaadin 8?

Upvotes: 0

Views: 1337

Answers (1)

Gergely Bacso
Gergely Bacso

Reputation: 14651

You could certainly do what you planned, but you have a much simpler solution there.

There is a specific function for turning combobox editable: javadoc

Upvotes: 1

Related Questions