Hi

I have an other solution for you. Use the updateActionListener tag (just available for MyFaces) within the comamandLink tag. With this tag you can set properties.

<t:updateActionListener value="#{node}" property="#{bean.node}" />

In case of a click to a node the updateActionListener is called and set the attribute node in the bean to the value node.

Then use in the commanlink the attribute styleClass as follows:
styleClass="#{node == bean.node ? 'blackbold':'blue'}">

This is very simple and works.

Hopefully this will help.

best regards Hans


2005/12/19, Kurt Edegger <[EMAIL PROTECTED]>:
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
>
>




--
mfg Hans Sowa
mailto:[EMAIL PROTECTED]

Reply via email to