PDA

View Full Version : NPE when adding a detached treeitem



zaccret
10 Jul 2008, 6:46 AM
GXT version : 1.2
GWT version : 1.5.3
Hosted mode
OS : Windows XP
Description :We get a NullPointerException if we add a TreeItem to another TreeItem which is not attached to a tree.

public class Test implements EntryPoint {
public void onModuleLoad() {
TreeItem root = new TreeItem("Options");
TreeItem subRoot = new TreeItem("Cameras");
root.add(subRoot);
}
}

zaccret
22 Jul 2008, 12:13 AM
Darell, this bug is still in 1.0.1

zaccret
28 Jul 2008, 1:29 AM
And the stack trace :

java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.tree.TreeItem.add(TreeItem.java:170)
at com.extjs.gxt.ui.client.widget.tree.TreeItem.add(TreeItem.java:152)
at test.gxt.client.Test.onModuleLoad(Test.java:13)

I suggest 2 solutions :
1 - (item -> tree) relation must be done on tree render instead of be done on add item
2 - simply throw a more explicit exception like illegalargument or illegalstateexception saying something like "the parent must first be add to a tree".

zaccret
17 Sep 2008, 2:24 AM
Still not resolved in last release.

zaccret
4 Nov 2008, 1:35 AM
Still in 1.1.2

zaccret
2 Dec 2008, 3:25 AM
I still get the issue with the last 1.2 release. I've added some information in the first post.

zaccret
3 Dec 2008, 2:15 AM
I've duplicated this issue in a cleaner thread : http://extjs.com/forum/showthread.php?p=258235