Description of the bug
When I add filter for in-memory items through ListDataView API for a Grid that doesn't have yet a data provider/items collections, I get an NullPointerException because inMemoryFilter not yet initialised.
Expected behavior
Vaadin Flow shouldn't throw NPE, but instead create an empty data provider lazily, i.e. once any methods of ListDataView is called.
Workaround: call grid.setItems(); before calling data view methods.
Minimal reproducible example
// create a Grid, but not assigning any items
Grid<Person> grid = new Grid<>();
// some TextField that adds a filter upon value change
searchField.addValueChangeListener(event -> {
if (Objects.nonNull(event.getValue())) {
this.gridListDataView.addFilter(item -> {
final String name = searchField.getValue().trim();
if (name.isEmpty()) {
return true;
}
return StringUtils.containsIgnoreCase(item.getName(), name);
});
}
});
Versions
- Vaadin / Flow version: 24.6.1 and older 24, 23 versions.
Description of the bug
When I add filter for in-memory items through
ListDataViewAPI for a Grid that doesn't have yet a data provider/items collections, I get anNullPointerExceptionbecauseinMemoryFilternot yet initialised.Expected behavior
Vaadin Flow shouldn't throw NPE, but instead create an empty data provider lazily, i.e. once any methods of ListDataView is called.
Workaround: call
grid.setItems();before calling data view methods.Minimal reproducible example
Versions