Searchbox

Hi all,

I need a simple searchbox, i.e., you type in a string and while typing, some suggestions appear below the textfield (similar to a combobox). A combobox itself is not an option because I do not want to perform filtering on an dataset but a ‘search’ on an unknown data basis. The input in the textfield field is used for an API-call which returns data which should be displayed below the textfield.

I found [this]
(https://vaadin.com/directory/component/searchbox) plugin but it seems that it is incompatible with Vaadin 18 (which I’m using) and I could not get it to work.

My next approach was to implement it myself with a combobox like [here]
(https://vaadin.com/forum/thread/18105975/dynamic-combobox-values-options-based-on-user-input) and lazy loading through a data provider but this did not work out in the end
(since Vaadin 18 the setDataProvider(…) is deprecated). Anyway, this seems more like an unclean hack which is why I would like to avoid dynamically changing the data base of the combobox.

Does someone have a suggestion? I’m really stuck. Currently my only plan would be to build a custom ‘notification’ that pops up on value changes of a textfield (which would propably look and feel weird …).

Best regards,
Roy

I have not tried this but would this work?

[https://vaadin.com/directory/component/autocomplete/samples]
(https://vaadin.com/directory/component/autocomplete/samples)

Ted carroll:
I have not tried this but would this work?

[https://vaadin.com/directory/component/autocomplete/samples]
(https://vaadin.com/directory/component/autocomplete/samples)

Hi,

thanks for the suggestion :slight_smile: I will give it a try! It seems like something that could work for me.

Best regards,

./edit:
Unfortunately I cannot get it to work. Whenever I try to instantiate an autocomplete object I get the following error message:

nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.gui.MainView]
: Constructor threw exception; nested exception is java.lang.IllegalStateException: UI instance is not available. It looks like you are trying to execute UI code outside the UI/Servlet dispatching thread