tags:

views:

357

answers:

1

With the standard GWT 2.0.3 API, how do you add a Clickhandler to the TreeItem? I'm hoping to implement asynchronous calls to the server that will retrieve the resulting TreeItems that are expanded.

Unfortunately FastTree doesn't work in GXT applications. Therefore I'm back to the original step of needing to attach handlers to TreeItems!

Are there any noticeable downfalls with this code:

Tree.addSelectionHandler(new SelectionHandler<TreeItem>()
{
    @Override
    public void onSelection(SelectionEvent event()
    {
        if(event.getSelectedItem == someTreeItem)
        {
            //Something
        }
    }
});
+2  A: 

With GWT's default Tree, there aren't handlers for specific TreeItems, just one SelectionHandler for the entire tree:

tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
  @Override
  public void onSelection(SelectionEvent event) {
    TreeItem item = event.getSelectedItem();
    // expand the selected item
  }
});

However, the GWT incubator's FastTree was literally built just for what you're trying to do, lazy-load the tree as items are expanded, so I would start there. Feel free to ask more questions if you have any.

Jason Hall
Thanks for that, matey. I'm finding it hard to understand a few of the more simpler things in GWT! I shall definitely drop you an e-mail (somehow!) if I get stuck any further. It's very much appreciated! Cheers
day_trader