summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorOlli Tietäväinen <ollit@vaadin.com>2019-07-12 10:44:55 +0300
committerZhe Sun <31067185+ZheSun88@users.noreply.github.com>2019-07-30 16:12:37 +0300
commit0630b9f33e30f7194c06fc4f7b123a3b88c62d65 (patch)
treeb740ee5ee919d69196dd5e6f0cef9fd3f467fe6b /server
parentbec223174d0d12416169c7f8bb8e29e879dc3316 (diff)
downloadvaadin-framework-0630b9f33e30f7194c06fc4f7b123a3b88c62d65.tar.gz
vaadin-framework-0630b9f33e30f7194c06fc4f7b123a3b88c62d65.zip
11642 refresh pagelength 0 combobox items after dataprovider update (#11653)
* Fixes #11642. ComboBox with pageLength 0 should be updated if DataProvider changes * added comments, fixed imports
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index c9622e1fd8..b9511450a5 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -28,17 +28,19 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
-import org.jsoup.nodes.Element;
-
-import com.vaadin.data.HasFilterableDataProvider;
-import com.vaadin.data.HasValue;
-import com.vaadin.data.ValueProvider;
import com.vaadin.data.provider.CallbackDataProvider;
+import com.vaadin.data.provider.DataChangeEvent;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataGenerator;
import com.vaadin.data.provider.DataKeyMapper;
import com.vaadin.data.provider.DataProvider;
+import com.vaadin.data.provider.InMemoryDataProvider;
import com.vaadin.data.provider.ListDataProvider;
+import org.jsoup.nodes.Element;
+
+import com.vaadin.data.HasFilterableDataProvider;
+import com.vaadin.data.HasValue;
+import com.vaadin.data.ValueProvider;
import com.vaadin.event.FieldEvents;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
@@ -219,6 +221,11 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
getState().currentFilterText = filterText;
filterSlot.accept(filterText);
}
+
+ @Override
+ public void resetForceDataSourceUpdate() {
+ getState().forceDataSourceUpdate = false;
+ }
};
/**
@@ -962,6 +969,20 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
filterSlot = filter -> providerFilterSlot
.accept(convertOrNull.apply(filter));
+
+ // This workaround is done to fix issue #11642 for unpaged comboboxes.
+ // Data sources for on the client need to be updated after data provider
+ // refreshAll so that serverside selection works even before the dropdown
+ // is opened. Only done for in-memory data providers for performance
+ // reasons.
+ if (dataProvider instanceof InMemoryDataProvider) {
+ dataProvider.addDataProviderListener(event -> {
+ if ((!(event instanceof DataChangeEvent.DataRefreshEvent))
+ && (getPageLength() == 0)) {
+ getState().forceDataSourceUpdate = true;
+ }
+ });
+ }
}
/**