diff options
-rw-r--r-- | server/src/com/vaadin/data/RpcDataProviderExtension.java | 5 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridDetailsServerTest.java | 29 |
2 files changed, 30 insertions, 4 deletions
diff --git a/server/src/com/vaadin/data/RpcDataProviderExtension.java b/server/src/com/vaadin/data/RpcDataProviderExtension.java index 62b8214cbd..620933c379 100644 --- a/server/src/com/vaadin/data/RpcDataProviderExtension.java +++ b/server/src/com/vaadin/data/RpcDataProviderExtension.java @@ -156,7 +156,10 @@ public class RpcDataProviderExtension extends AbstractExtension { } indexToItemId.forcePut(index, itemId); - detailComponentManager.createDetails(itemId, index); + + if (visibleDetails.contains(itemId)) { + detailComponentManager.createDetails(itemId, index); + } } index++; } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridDetailsServerTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridDetailsServerTest.java index e9e32cb1ca..e9b5b688d1 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridDetailsServerTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridDetailsServerTest.java @@ -17,7 +17,6 @@ package com.vaadin.tests.components.grid.basicfeatures.server; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -76,8 +75,7 @@ public class GridDetailsServerTest extends GridBasicFeaturesTest { selectMenuPath(FIRST_ITEM_DETAILS); selectMenuPath(FIRST_ITEM_DETAILS); - // this will throw before assertNull - assertNull(getGridElement().getDetails(0)); + getGridElement().getDetails(0); } @Test @@ -120,6 +118,31 @@ public class GridDetailsServerTest extends GridBasicFeaturesTest { details.findElement(By.className("v-widget"))); } + @Test(expected = NoSuchElementException.class) + public void scrollingDoesNotCreateAFloodOfDetailsRows() { + selectMenuPath(CUSTOM_DETAILS_GENERATOR); + + // scroll somewhere to hit uncached rows + getGridElement().scrollToRow(101); + + // this should throw + getGridElement().getDetails(100); + } + + @Test + public void openingDetailsOutOfView() { + getGridElement().scrollToRow(500); + + selectMenuPath(CUSTOM_DETAILS_GENERATOR); + selectMenuPath(FIRST_ITEM_DETAILS); + + getGridElement().scrollToRow(0); + + // if this fails, it'll fail before the assertNotNull + assertNotNull("unexpected null details row", getGridElement() + .getDetails(0)); + } + @Test public void togglingAVisibleDetailsRowWithOneRoundtrip() { selectMenuPath(CUSTOM_DETAILS_GENERATOR); |