Hello,

My (short) experiences shows that the getNode() method returns the node
which is selected in the htmlTree. Then the getNode() method returns the
selected node only in your selection event or via the htmlTree, when you
have set it explicitely.

What I do is as follows:
- in my selectNode method (actionListener), I take the selectedNodeId
and set the selected node of the htmlTree.

    public void selectNode(ActionEvent event)
    {
        // set the selected status on the node of the tree
        htmlTree.setNodeSelected(event);
        selectedNodeId = htmlTree.getNodeId();
    }

- in the other actionListeners, I access the selected node by using the
selectedNodeId.

    public void addNode(ActionEvent event)
    {
        // get access to the selected node 
        htmlTree.setNodeId(selectedNodeId);
        MyTreeNode node = ((MyTreeNode) treeModel.getNode());
        .
        .
        .
    }

The used variables being declared as follows (with getters and setters
of course):

    private TreeModel                   treeModel;
    private transient HtmlTree          htmlTree;

    private MyTreeNode                  selectedNode;
    private String                      selectedNodeId;

This is maybe not THE solution, but it works.
Hope this helps,

Bye, Dan


Reply via email to