From c63f0db47a2ae65583cde9108fa9f5b852b153e7 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Mon, 28 Nov 2011 11:17:11 +0000 Subject: [PATCH] #7988 TreeTable.setCollapsed() should not throw NPE if the component has not been rendered yet svn changeset:22147/svn branch:6.7 --- src/com/vaadin/ui/Table.java | 8 ++++++-- src/com/vaadin/ui/TreeTable.java | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index f8fe76a522..cd07465d07 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -3816,8 +3816,12 @@ public class Table extends AbstractSelect implements Action.Container, final LinkedList visible = new LinkedList(); final Object[][] cells = getVisibleCells(); - for (int i = 0; i < cells[CELL_ITEMID].length; i++) { - visible.add(cells[CELL_ITEMID][i]); + // may be null if the table has not been rendered yet (e.g. not attached + // to a layout) + if (null != cells) { + for (int i = 0; i < cells[CELL_ITEMID].length; i++) { + visible.add(cells[CELL_ITEMID][i]); + } } return visible; diff --git a/src/com/vaadin/ui/TreeTable.java b/src/com/vaadin/ui/TreeTable.java index fa80476fc8..171ee616e1 100644 --- a/src/com/vaadin/ui/TreeTable.java +++ b/src/com/vaadin/ui/TreeTable.java @@ -657,8 +657,8 @@ public class TreeTable extends Table implements Hierarchical { */ public void setCollapsed(Object itemId, boolean collapsed) { if (isCollapsed(itemId) != collapsed) { - if (null == toggledItemId && getVisibleItemIds().contains(itemId) - && !isRowCacheInvalidated()) { + if (null == toggledItemId && !isRowCacheInvalidated() + && getVisibleItemIds().contains(itemId)) { // optimization: partial refresh if only one item is // collapsed/expanded toggledItemId = itemId; -- 2.39.5