Displaying in Vaadin Combobox data from database via CrudeRepository

What is the best solution for displaying in Vaadin Combobox data from database via CrudRepository in SpringBoot application?
Can I use Binder class for this? In Grid it’s very simple, for example: grid.setItems(somethingRepo.findAll()).
What I must have for Combobox?

comboBox.setItemLabelGenerator(SomethingClass::getTitle); // pass the method that returns the String that should be displayed for that option
// like above, but the renderer is used for the selected item. I think this is optional and would fall back to the item label generator. But with a renderer (ComponentRenderer), you can return vaadin components instead of Strings if you want.
comboBox.setRenderer(item -> item.getTitle()); 

You’d use a Binder to bind the selected value to some bean. But it has nothing to do with the available options, which you want to load from repository.

You can also use a DataProvider callback, that provides you the typed in filter value (e.g. “ABC”) plus the current entry indexes the combobox wants to show to use full blown lazy loading. That allows you to easily also show big data sets in a CB without the need to load it all at once.


Many thanks for the answers. I chose setItemLabelGenerator, but probably DataProvider will be also helpful. I found that comboBox.setItems(somethingRepo.findAll()) doesn’t work with CRUDRepository so I changed repo to JPA.
I understand that Binder class is only useful for saving input data to database. Lead me out of my mistake.