diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-01-25 14:36:51 +0200 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-01-25 14:36:51 +0200 |
commit | 2f6f2970bc8ea8bb7d4745b9e87255874ef9fb5e (patch) | |
tree | 67fd727ae9e58932ebc3fec2fa4d46c6b4fac15c /uitest/src/main/java | |
parent | cf0d3dcc5ad32285b91e7d998cf628ef9c83da55 (diff) | |
download | vaadin-framework-2f6f2970bc8ea8bb7d4745b9e87255874ef9fb5e.tar.gz vaadin-framework-2f6f2970bc8ea8bb7d4745b9e87255874ef9fb5e.zip |
Fix Grid not updating selected item immediately (#10569)
Diffstat (limited to 'uitest/src/main/java')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/data/DataProviderRefresh.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/data/DataProviderRefresh.java b/uitest/src/main/java/com/vaadin/tests/data/DataProviderRefresh.java index 9f1591407c..faec5084f7 100644 --- a/uitest/src/main/java/com/vaadin/tests/data/DataProviderRefresh.java +++ b/uitest/src/main/java/com/vaadin/tests/data/DataProviderRefresh.java @@ -3,16 +3,17 @@ package com.vaadin.tests.data; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.stream.Stream; import com.vaadin.data.provider.AbstractDataProvider; import com.vaadin.data.provider.Query; import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; import com.vaadin.ui.Grid; -public class DataProviderRefresh extends AbstractTestUI { +public class DataProviderRefresh extends AbstractTestUIWithLog { public static class Bean implements Serializable { @@ -96,9 +97,10 @@ public class DataProviderRefresh extends AbstractTestUI { } } + private Grid<Bean> grid = new Grid<>(); + @Override protected void setup(VaadinRequest request) { - Grid<Bean> grid = new Grid<>(); List<Bean> arrayList = new ArrayList<>(); Bean foo = new Bean("Foo", 10); arrayList.add(foo); @@ -108,9 +110,19 @@ public class DataProviderRefresh extends AbstractTestUI { grid.setDataProvider(dataProvider); grid.addColumn(Object::toString).setCaption("toString"); addComponent(grid); - addComponent(new Button("Replace item", - event -> dataProvider.refreshItem(new Bean("Bar", 10)))); + addComponent(new Button("Replace item", event -> { + dataProvider.refreshItem(new Bean("Bar", 10)); + logSelectedItem(grid.asSingleSelect().getValue()); + })); addComponent(new Button("Select old", event -> grid.select(foo))); + grid.asSingleSelect().addValueChangeListener(e -> { + logSelectedItem(e.getValue()); + }); } + private void logSelectedItem(Bean bean) { + Optional.ofNullable(bean) + .map(b -> "Currently selected: " + b.toString()) + .ifPresent(this::log); + } } |