use of com.vaadin.flow.data.provider.DataProvider in project flow-components by vaadin.
the class Select method reset.
@SuppressWarnings("unchecked")
private void reset() {
keyMapper.removeAll();
listBox.removeAll();
clear();
requestClientSideContentUpdateIfNotPending();
if (isEmptySelectionAllowed()) {
addEmptySelectionItem();
}
synchronized (dataProvider) {
final AtomicInteger itemCounter = new AtomicInteger(0);
getDataProvider().fetch(DataViewUtils.getQuery(this)).map(item -> createItem((T) item)).forEach(component -> {
add((Component) component);
itemCounter.incrementAndGet();
});
lastFetchedDataSize = itemCounter.get();
// so as to avoid multiple beforeClientResponses.
if (sizeRequest == null) {
sizeRequest = ui -> {
fireSizeEvent();
sizeRequest = null;
};
// Size event is fired before client response so as to avoid
// multiple size change events during server round trips
runBeforeClientResponse(sizeRequest);
}
}
}
Aggregations