]> source.dussan.org Git - vaadin-framework.git/commitdiff
#7988 TreeTable.setCollapsed() should not throw NPE if the component has not been...
authorHenri Sara <henri.sara@itmill.com>
Mon, 28 Nov 2011 11:17:11 +0000 (11:17 +0000)
committerHenri Sara <henri.sara@itmill.com>
Mon, 28 Nov 2011 11:17:11 +0000 (11:17 +0000)
svn changeset:22147/svn branch:6.7

src/com/vaadin/ui/Table.java
src/com/vaadin/ui/TreeTable.java

index f8fe76a522e7733eb0d68ad62d53fecf27e08b12..cd07465d076fbd948653f3bd5549ce9c7a825566 100644 (file)
@@ -3816,8 +3816,12 @@ public class Table extends AbstractSelect implements Action.Container,
         final LinkedList<Object> visible = new LinkedList<Object>();
 
         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;
index fa80476fc82bf8586f3428f2bd58318b6c34e0d4..171ee616e1be6bfbe6e3f21fbf330c43b86d7c87 100644 (file)
@@ -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;