PDA

View Full Version : [FNR] Expanding more TreeItems with AsyncTreePage not possible



Christian Hemker
10 Jul 2008, 11:46 AM
Hello,
This is a second Post of the same Problem,
but now in the GXT Bugs Forum. http://extjs.com/forum/showthread.php?t=39967

I used the sample Async Tree from the Ext GWT explorer demo you provide with the Release Version gxt-1.0.
I want to expand the first level of all rootItems.
From the Thread http://extjs.com/forum/showthread.php?t=39967 I got the idea how to do that.

I use a Listener for the load Event with loader.addLoadListener( new Listener())
and then I get the rootItems from the binder.findItem() to call the
treeItem.setExpanded(true) on all of them:



loader.load(null);
loader.addLoadListener( new LoadListener(){

@Override
public void loaderLoad(LoadEvent le) {

if( isRootInited == false){
isRootInited = true;
List<FileModel> rootItems = store.getRootItems();
for (final FileModel model : rootItems) {

if( model != null ) {
TreeItem item = (TreeItem) binder.findItem( model);
// can not proove if item.isLeaf() because the children are not added at the moment

if( item != null ) {
item.setExpanded(true);
}
}
}
}
super.loaderLoad(le);
}
});
This works if I call setExpanded(true) on only one TreeItem.
If I call it on more than one TreeItem in the same level I get
the following NullPointerException in Host mode.


java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.tree.TreeItemUI.aft erExpand(TreeItemUI.java:74)
at com.extjs.gxt.ui.client.widget.tree.TreeItemUI$2.h andleEvent(TreeItemUI.java:91)
at com.extjs.gxt.ui.client.widget.tree.TreeItemUI$2.h andleEvent(TreeItemUI.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.fireE vent(BaseObservable.java:74)
at com.extjs.gxt.ui.client.fx.Fx.onComplete(Fx.java:1 65)
at com.extjs.gxt.ui.client.fx.Fx$1.onComplete(Fx.java :67)
at com.google.gwt.animation.client.Animation.update(A nimation.java:217)
at com.google.gwt.animation.client.Animation.updateAn imations(Animation.java:52)
at com.google.gwt.animation.client.Animation.access$0 (Animation.java:47)
at com.google.gwt.animation.client.Animation$1.run(An imation.java:133)It is possible to avoid the exception if I call tree.setAnimate(false)
before the tree is given to the binder.
But the result is, that the tree only opens and shows the children of one parent,
and not the whole tree. The parents are gone and the second children are also not available.

OS: Windows XP
GXT Version: gxt-1.0
Effect occours in hosted and web mode
Browser: IE 7.0

To reproduce this you can change the newest Download of the explorer Sample from gxt-1.0.
I have only changed the Files in my attachment.

com.extjs.gxt.samples.explorer.client.pages.AsyncTreePage
com.extjs.gxt.samples.explorer.server.FileServiceImpl

When you call the Async Tree you see the problem.

How can I expand more than one TreeItem directly in Java?

Thanks,
Christian

darrellmeyer
10 Jul 2008, 7:31 PM
I took a look at your code and am not sure I understand your problem. In your listener, you loop through the root items and expand them. In this case, there is only 1 root item, and it expands just fine. Am I missing something?

Christian Hemker
10 Jul 2008, 7:56 PM
Yes. I have changed the input of the FileServiceImpl to get more than one rootItem.
The changed code is also in my attachment.



public class FileServiceImpl extends RemoteServiceServlet implements FileService {
private File root;
private FilenameFilter filter;
public FileServiceImpl() {
URL rootUrl = getClass().getClassLoader().getResource("com/extjs/gxt/samples");



In that case I run into the problem the exception occured and the tree is not complete anymore.

Thanks,
Christian

darrellmeyer
10 Jul 2008, 8:54 PM
I thought I grabbed both files but must not have got the second one. There was a nasty bug with tree loader that I was able to track down. So your code works with the fix, all root items are visible and expanded. However, you will need to keep animations disabled. I need to review the animation code at a later time.

The fix is in SVN.

Christian Hemker
11 Jul 2008, 12:54 AM
Darrell,
Thanks for your quick response. :)
Actually I have no access to SVN.
As soon as I have access I will post the result.

Christian Hemker
4 Aug 2008, 1:26 PM
Hi,
I have disabled the animation with
tree.setAnimate(false);and the exception is gone.

I have tested the LoadListener with the gxt 1.0.1 download,
but the problem is still there.

In the Tree I want to see all direct children of com/extjs/gxt/samples. I.E.
8509
I can only manually create this state of the tree.

If I call the AsyncTreePage with the LoadListener (described before)
I get only the children of com/extjs/gxt/samples/explorer
or of com/extjs/gxt/samples/rescources randomly.

8507

What's going wrong?

Greets,
Christian