You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 itemsGrid<Person> grid = newGrid<>();
// some TextField that adds a filter upon value changesearchField.addValueChangeListener(event -> {
if (Objects.nonNull(event.getValue())) {
this.gridListDataView.addFilter(item -> {
finalStringname = searchField.getValue().trim();
if (name.isEmpty()) {
returntrue;
}
returnStringUtils.containsIgnoreCase(item.getName(), name);
});
}
});
Versions
Vaadin / Flow version: 24.6.1 and older 24, 23 versions.
The text was updated successfully, but these errors were encountered:
mshabarov
changed the title
ListDataView throws NPE when no items or data provider have been set before accessing items
ListDataView throws NPE when no items or data provider have been set before adding a filter
Jan 9, 2025
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 anNullPointerException
becauseinMemoryFilter
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
Versions
The text was updated successfully, but these errors were encountered: