From 048bd83480551cc4f88dfc9de8e2e17ac6261885 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 11 Aug 2015 14:55:27 +0300 Subject: [PATCH] Fix Grid client-side NPE finding uneditable column editor (#18589) Change-Id: I53e7cb95cf2828f966db5b41c07c38fb756372f3 --- .../src/com/vaadin/client/widgets/Grid.java | 20 ++++++++++++++----- .../basicfeatures/server/GridEditorTest.java | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 8db6e9a55a..ce3db0970a 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -6745,11 +6745,21 @@ public class Grid extends ResizeComposite implements if (args.getIndicesLength() == 0) { return editor.editorOverlay; - } else if (args.getIndicesLength() == 1 - && args.getIndex(0) < columns.size()) { - escalator - .scrollToColumn(args.getIndex(0), ScrollDestination.ANY, 0); - return editor.getWidget(columns.get(args.getIndex(0))).getElement(); + } else if (args.getIndicesLength() == 1) { + int index = args.getIndex(0); + if (index >= columns.size()) { + return null; + } + + escalator.scrollToColumn(index, ScrollDestination.ANY, 0); + Widget widget = editor.getWidget(columns.get(index)); + + if (widget != null) { + return widget.getElement(); + } + + // No widget for the column. + return null; } return null; diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java index b77cc41946..e772ed44e9 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java @@ -365,6 +365,7 @@ public class GridEditorTest extends GridBasicFeaturesTest { .findElements(By.xpath("./div")).get(3) .getAttribute("class")); + assertNoErrorNotifications(); } private WebElement getSaveButton() { -- 2.39.5