]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for Grid declarative format (read). (#8050)
authorDenis <denis@vaadin.com>
Tue, 20 Dec 2016 07:53:33 +0000 (09:53 +0200)
committerPekka Hyvönen <pekka@vaadin.com>
Tue, 20 Dec 2016 07:53:33 +0000 (09:53 +0200)
* Fix for Grid declarative format (read).

Fixes vaadin/framework8-issues#576

server/src/main/java/com/vaadin/ui/Grid.java
server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java

index b7a3690f034d7945c8559bbe6f340a92efac8395..73d5c986f819c82eea49efaf34d273947c62ffd3 100644 (file)
@@ -77,6 +77,7 @@ import com.vaadin.shared.ui.grid.GridState;
 import com.vaadin.shared.ui.grid.GridStaticCellType;
 import com.vaadin.shared.ui.grid.HeightMode;
 import com.vaadin.shared.ui.grid.SectionState;
+import com.vaadin.ui.Grid.SelectionMode;
 import com.vaadin.ui.components.grid.ColumnReorderListener;
 import com.vaadin.ui.components.grid.ColumnResizeListener;
 import com.vaadin.ui.components.grid.ColumnVisibilityChangeListener;
@@ -3050,6 +3051,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
         List<T> items = new ArrayList<>();
         for (Element row : body.children()) {
             T item = deserializeDeclarativeRepresentation(row.attr("item"));
+            items.add(item);
             if (row.hasAttr("selected")) {
                 getSelectionModel().select(item);
             }
index 70e6539a48ab61995c9538b9899826831ac8122c..d8b75b130e73f8755a6764a1277beae1d352cf83 100644 (file)
@@ -28,6 +28,7 @@ import org.junit.Test;
 import com.vaadin.data.SelectionModel.Multi;
 import com.vaadin.data.SelectionModel.Single;
 import com.vaadin.data.provider.DataProvider;
+import com.vaadin.data.provider.Query;
 import com.vaadin.shared.ui.grid.HeightMode;
 import com.vaadin.shared.ui.label.ContentMode;
 import com.vaadin.tests.data.bean.Person;
@@ -264,7 +265,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> {
                 person2.getFirstName(), person2.getLastName(),
                 getComponentTag());
 
-        testRead(design, grid);
+        Grid<?> readGrid = testRead(design, grid, true, true);
+        Assert.assertEquals(2, readGrid.getDataProvider().size(new Query<>()));
         testWrite(design, grid, true);
     }
 
@@ -313,7 +315,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> {
                 person3.toString(), person3.getFirstName(),
                 person3.getLastName(), getComponentTag());
 
-        testRead(design, grid);
+        Grid<?> readGrid = testRead(design, grid, true, true);
+        Assert.assertEquals(3, readGrid.getDataProvider().size(new Query<>()));
         testWrite(design, grid, true);
     }
 
@@ -347,7 +350,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> {
                 person2.getFirstName(), person2.getLastName(),
                 getComponentTag());
 
-        testRead(design, grid);
+        Grid<?> readGrid = testRead(design, grid, true, true);
+        Assert.assertEquals(2, readGrid.getDataProvider().size(new Query<>()));
         testWrite(design, grid, true);
     }
 
@@ -382,7 +386,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> {
                 person2.toString(), person2.getFirstName(),
                 person2.getLastName(), getComponentTag());
 
-        testRead(design, grid);
+        Grid<?> readGrid = testRead(design, grid, true, true);
+        Assert.assertEquals(2, readGrid.getDataProvider().size(new Query<>()));
         testWrite(design, grid, true);
 
         grid.setSelectionMode(SelectionMode.SINGLE);
@@ -394,7 +399,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> {
                 person2.getFirstName(), person2.getLastName(),
                 getComponentTag());
 
-        testRead(design, grid);
+        readGrid = testRead(design, grid, true, true);
+        Assert.assertEquals(2, readGrid.getDataProvider().size(new Query<>()));
         testWrite(design, grid, true);
     }