aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-12-01 13:54:29 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-12-22 11:24:43 +0000
commit0404d39ac566c83c6d8127945f9dcf1e73958938 (patch)
tree48baf5bc2307c41fc154477d1e60905b28c5f1e9 /client/src
parent5bed76664451af587f39a3d548f11ec210e38167 (diff)
downloadvaadin-framework-0404d39ac566c83c6d8127945f9dcf1e73958938.tar.gz
vaadin-framework-0404d39ac566c83c6d8127945f9dcf1e73958938.zip
Fix WidgetRenderer column cells not correctly init on change (#19086)
When changing to a widget renderer with an existing column, the widget renderer expects that the cells would be initialized to have a correct widget for it. Because of original design where you could not change renderers, this was not taken into account and cells did not get reinitialized when changing the renderer. This patch showed another underlying detach problem from removing a widget renderer and destroying complex renderers. These both are also addressed to make this bug possible to test correctly. Patch includes a client-side test that verifies the integrity of the renderer state in different stages of its lifecycle. Change-Id: I67330e5d07c95047cb69040e8355a17dc8a96f08
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/connectors/MultiSelectionModelConnector.java1
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java30
2 files changed, 29 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/connectors/MultiSelectionModelConnector.java b/client/src/com/vaadin/client/connectors/MultiSelectionModelConnector.java
index 04c56a5b44..5d00619995 100644
--- a/client/src/com/vaadin/client/connectors/MultiSelectionModelConnector.java
+++ b/client/src/com/vaadin/client/connectors/MultiSelectionModelConnector.java
@@ -128,7 +128,6 @@ public class MultiSelectionModelConnector extends
}
});
} else if (renderer != null) {
- renderer.destroy();
selectAll.removeHandler();
dataAvailable.removeHandler();
renderer = null;
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index f96ee69010..806bc6a220 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -4791,8 +4791,36 @@ public class Grid<T> extends ResizeComposite implements
}
if (renderer != bodyRenderer) {
+ // Variables used to restore removed column.
+ boolean columnRemoved = false;
+ double widthInConfiguration = 0.0d;
+ ColumnConfiguration conf = null;
+ int index = 0;
+
+ if (grid != null
+ && (bodyRenderer instanceof WidgetRenderer || renderer instanceof WidgetRenderer)) {
+ // Column needs to be recreated.
+ index = grid.getColumns().indexOf(this);
+ conf = grid.escalator.getColumnConfiguration();
+ widthInConfiguration = conf.getColumnWidth(index);
+
+ conf.removeColumns(index, 1);
+ columnRemoved = true;
+ }
+
+ // Complex renderers need to be destroyed.
+ if (bodyRenderer instanceof ComplexRenderer) {
+ ((ComplexRenderer) bodyRenderer).destroy();
+ }
+
bodyRenderer = renderer;
+ if (columnRemoved) {
+ // Restore the column.
+ conf.insertColumns(index, 1);
+ conf.setColumnWidth(index, widthInConfiguration);
+ }
+
if (grid != null) {
grid.refreshBody();
}
@@ -5486,7 +5514,7 @@ public class Grid<T> extends ResizeComposite implements
if (renderer instanceof WidgetRenderer) {
try {
Widget w = WidgetUtil.findWidget(cell.getElement()
- .getFirstChildElement(), Widget.class);
+ .getFirstChildElement(), null);
if (w != null) {
// Logical detach