Eyvind Almqvist
Eyvind Almqvist

Reputation: 332

How to preselect an item from a ComboBox in Vaadin?

There is no select method in the ComboBox class. Is there any other to preselect an item in a Vaadin Combobox? This is my code:

final ComboBox<ReportTypeEnum> selectionBox = new ComboBox<>("Rapporttyp");
selectionBox.setWidthFull();
selectionBox.setItems(getPatentNationalReportTypeList());
selectionBox.addValueChangeListener(e -> setVisibilityOfGenerateReportTypeButton());

Upvotes: 0

Views: 33

Answers (1)

Simon Martinelli
Simon Martinelli

Reputation: 36223

As ComboBox implements HasValue you have to call setValue()

HasValueis used by all components that represent a Value:

https://vaadin.com/api/platform/current/com/vaadin/flow/component/HasValue.html

Upvotes: 2

Related Questions