summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/com/vaadin/ui/Grid.java15
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/grid/GridContainerTest.java22
2 files changed, 35 insertions, 2 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 0774afd582..06ab8d1581 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -312,7 +312,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
*
* @see #setDetailsGenerator(DetailsGenerator)
*/
- private DetailsGenerator detailsGenerator = DetailsGenerator.NULL;
+ private DetailsGenerator detailsGenerator;
/**
* This map represents all details that are currently visible on the
@@ -334,7 +334,13 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
private final Set<Object> openDetails = new HashSet<Object>();
public DetailComponentManager(Grid grid) {
+ this(grid, DetailsGenerator.NULL);
+ }
+
+ public DetailComponentManager(Grid grid,
+ DetailsGenerator detailsGenerator) {
super(grid);
+ setDetailsGenerator(detailsGenerator);
}
/**
@@ -4914,7 +4920,12 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
}
}
- detailComponentManager = new DetailComponentManager(this);
+ if (detailComponentManager != null) {
+ detailComponentManager = new DetailComponentManager(this,
+ detailComponentManager.getDetailsGenerator());
+ } else {
+ detailComponentManager = new DetailComponentManager(this);
+ }
/*
* selectionModel == null when the invocation comes from the
diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridContainerTest.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridContainerTest.java
index 527568eac8..079487d01f 100644
--- a/server/tests/src/com/vaadin/tests/server/component/grid/GridContainerTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridContainerTest.java
@@ -19,11 +19,33 @@ import org.junit.Assert;
import org.junit.Test;
import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.ui.Component;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.DetailsGenerator;
+import com.vaadin.ui.Grid.RowReference;
+import com.vaadin.ui.Label;
public class GridContainerTest {
@Test
+ public void testDetailsGeneratorDoesNotResetOnContainerChange() {
+ Grid grid = new Grid();
+ DetailsGenerator detGen = new DetailsGenerator() {
+
+ @Override
+ public Component getDetails(RowReference rowReference) {
+ return new Label("Empty details");
+ }
+ };
+ grid.setDetailsGenerator(detGen);
+
+ grid.setContainerDataSource(createContainer());
+
+ Assert.assertEquals("DetailsGenerator changed", detGen,
+ grid.getDetailsGenerator());
+ }
+
+ @Test
public void testSetContainerTwice() throws Exception {
TestGrid grid = new TestGrid();