I have the same scenario, and the only way I figured out to do it was to
have the action listener on the command link invoke a managed bean method
instead of "#{t.setNodeSelected}" as normal. This is in order to get to the
ActionEvent, from which you can walk the component tree to get a reference
to the Tree2 component. Then you call UITreeData.setNodeSelected() in the
same way that Tree2 would do if you used actionListener="#{t.setNodeSelected}",
and because you're calling it yourself, you can also save a reference to the
selected node in the managed bean. My code looks like this:
...
<h:commandLink immediate="true" styleClass="#{
t.nodeSelected ? 'documentSelected':'document'}"
actionListener="#{treeBacker.setNodeSelected}"
action="#{treeBacker.actionSelectNode}">
<h:outputText value="#{node.description}"
styleClass="#{node.style}"/>
<h:outputText value=" (#{node.childCount}) "
styleClass="childCount" />
<h:outputText value="*" styleClass="#{node.style}"
rendered="#{node.pendingOrWarning}" />
</h:commandLink>
...
in TreeBacker:
/**
* Sets the selected node in the Tree2 component as well as this backing
bean.
* In Tomahawk 1.1.1, this method was unnecessary, as the selected node
could
* be obtained from the TreeModel; however, this was removed in 1.1.3.
*
* @param event Faces ActionEvent
*/
public void setNodeSelected (ActionEvent event)
{
UIComponent component = event.getComponent();
UITreeData tree2 = null;
// Find first parent tree component
while (component != null)
{
component = component.getParent();
if (component instanceof UITreeData)
{
tree2 = (UITreeData) component;
break;
}
}
// Set selected node and remember it in the action listener
if (tree2 != null) {
// Set new selected node
tree2.setNodeSelected(event);
this.selectedNode = tree2.getNode();
}
}
I've used this method bound to an action listener in the command link
On 11/29/06, Anthony Hong <[EMAIL PROTECTED]> wrote:
Currently, when I click leaf node, a navigation is made to a new page.
I want to know the whole path by this leaf node.
I saw there is no method provided for retrieve parent by current tree
node or tree state.
Please help. Thanks
--
Anthony Hong
--
David Chandler
Development Coach
learnjsf.com