> If there was a way to remotely set the currently
> selected node in tree2 that would be fantastic.
> 
> Possibly setting the nodeselected in the backing tree
> bean or something?

It would be possible but I don't think this would be very useful in
too many situations.  I would imagine that the most common scenario of
a node being "selected" would come from direct user manipulation of
the tree.  Your scenario involves "selecting" the node for the user
because of an action taken in a popup window.  That's fine but I don't
think its too common.

Here are a couple of alternatives for you to consider:

1.) Try to make this work with the existing code base.  You could
write your own subclass of TreeNodeBase.  TreeNodeBase is really just
the bare minimum you need, it was intended to be subclassed.  You
could have a selected property in this node class that you could set
yourself.  Then you could use the "node" reference to determine
whether or not to render the node as selected.

<x:tree2 id="clientTree" value="#{treeBacker.treeData}" var="node"
varNodeToggler="t">

...

   <f:facet name="document">
    <h:panelGroup>
      <h:commandLink immediate="true" styleClass="document"
actionListener="#{t.setNodeSelected}" rendered="#{!node.selected}">
        <h:graphicImage value="/images/document.png" border="0"/>
        <h:outputText value="#{node.description}"/>
        <f:param name="docNum" value="#{node.identifier}"/>
      </h:commandLink>
      <h:commandLink immediate="true" styleClass="documentSelected"
actionListener="#{t.setNodeSelected}" rendered="#{node.selected}">
        <h:graphicImage value="/images/document.png" border="0"/>
        <h:outputText value="#{node.description}"/>
        <f:param name="docNum" value="#{node.identifier}"/>
      </h:commandLink>
    </h:panelGroup>
  </f:facet>

...

</x:tree2>

You would take care of maintaining the selected value of the nodes
yourself which should be easy enough to do since you can access the
tree data at any time.

2.) Subclass HtmlTree and provide a method to set the selected value
of the node.  This might be even easier than option#1.

HTH,

sean

Reply via email to