Hi Daniel,
thank you for your answer. That's probably a better way than using
another bean property to store the selected node in the listener. But
why and when is the tree.getNode() reset? If you set the node
explicitely by tree.setNodeSelected(evt) is this persistent until the
next node is selected?
Thank you again and sorry for the late response,
Kurt
on 12/14/2005 2:53 AM Lefevre, Daniel stated:
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