Vaadin 8: Combobox and Dataprovider with Filtering?

Hey guys,

has anyone an example how to use a Combobox with a Dataprovider, which uses the Input from combobox as Filtering?
I read this
but i do not realy understand how to use
setItems(CaptionFilter, Collection)

a quick example would be realy nice.

Best regards

after more Try&Catch i have a first solution found my own way.

    private ComboBox<EveItemDto> getFilterCombo() {
        if(filtercombo == null){
            filtercombo = new ComboBox<>("Search EVE Item");
            filtercombo.setWidth(100, Unit.PERCENTAGE);
            filtercombo.setEmptySelectionCaption("Search for an Item ...");
            filtercombo.setItemIconGenerator((EveItemDto item) -> {
                if(item.getIconFile() != null && !item.getIconFile().isEmpty()){
                    return new ThemeResource(item.getIconFile());
                    return new ThemeResource(EMPTY_ICON);
            filtercombo.setDataProvider((String filter, int offset, int limit) -> {
                if(filter.isEmpty() == false){
                    return presenter.getFoundDatas().stream();
                    return presenter.getEmptyList().stream();
            }, (String value) -> {
                if(value.isEmpty() == false){
                    return presenter.findEveItems(value);
                    return presenter.getEmptyList().size();
        return filtercombo;

But are there better ways? or is this correct?
How can i manipulate the limit value?

Hmm. Java 8 lambdas are nice but perhaps a concrete filter class on the dataprovider would be more useful in this case? If you hold a reference to it, you can change the parameters that affects the filtering, I would think.

hey nicklas,

sound logical. i will give it a try. at all this was my first usable result :wink: