Jon,
Here is a portion of a previous email I sent on the subject. Let me
know if there is still any confusion.
sean
[snip]
I've added a isNodeSelected() method to the tree so that it can be
accessed via a
value binding expression.
All that is required (if you want to use this functionality) is to set
the action listener of the commandLink as in this JSP.
<f:facet name="document">
<h:panelGroup>
<h:commandLink immediate="true" styleClass="document"
actionListener="#{t.setNodeSelected}" rendered="#{!t.nodeSelected}">
<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="#{t.nodeSelected}">
<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>
In fact the new tree is now even more powerful than the current tree
in this regard because you can control what constitutes node
selection. So if you didn't want the selection of a branch node to be
counted as a node selection you now have that option. Of course you
can always configure it to behave exactly the same as the current tree
if that is your wish (or ignore node selection entirely.)
[snip]
On Wed, 23 Mar 2005 16:47:43 -0800, Jon Travis <[EMAIL PROTECTED]> wrote:
> I know there was some discussion on the -dev list about
> tree2 selection differences between tree1.
>
> One of the things that I'm liking about Tree1 is the
> ability to easily show which nodes are selected (they
> are bolded, hilighted, etc.)
>
> Does this feature exist in tree2? I basically need
> the ability to set the selected tree nodes from the
> model & have them visually cued.
>
> -- Jon
>
>
> On Mar 18, 2005, at 10:34 AM, Borja Mart�n wrote:
>
> > Yes, I could get the selected node without problem. I paste the code
> > snippet in case it could help anyone else:
> > <x:tree2 id="secciones"
> > value="#{sections.data}"
> > var="section"
> > varNodeToggler="t">
> > <f:facet name="section">
> > <h:panelGroup>
> > <f:facet name="expand">
> > <h:graphicImage value="images/yellow-folder-open.png"
> > rendered="#{t.nodeExpanded}" border="0"/>
> > </f:facet>
> > <f:facet name="collapse">
> > <h:graphicImage value="images/yellow-folder-closed.png"
> > rendered="#{!t.nodeExpanded}" border="0"/>
> > </f:facet>
> > <h:commandLink
> > actionListener="#{sections.select}">
> > <h:outputText value="#{section.description}" />
> > </h:commandLink>
> > </h:panelGroup>
> > </f:facet>
> > </x:tree2>
> >
> > public void select(ActionEvent ae)
> > {
> > UIComponent comp = ae.getComponent();
> > HtmlTree tree = (HtmlTree) comp.getParent().getParent();
> > TreeNodeBase node = tree.getNode();
> > }
> >
> > bye!
> >
> > Sean Schofield wrote:
> >
> >> x:treeselectionlistener is for tree. Tree2 does not use that (as you
> >> have probably figured out already.) Tree2 can use an action listener
> >> to indicate which node was selected (similar to what you were trying.)
> >>
> >> Do you have it working now? It sounded like from your last message
> >> that you are ok with tree2 and node selection now.
> >>
> >> sean
> >>
> >> On Fri, 18 Mar 2005 19:13:47 +0100, Borja Mart�n <[EMAIL PROTECTED]>
> >> wrote:
> >>
> >>> sorry, but the problem was that I had some html without the
> >>> f:verbatim
> >>> tags and that's why the actions weren't called
> >>>
> >>> Borja Mart�n wrote:
> >>>
> >>>
> >>>> hi,
> >>>> I was trying to get the tree2 working and have found that the
> >>>> TreeSelectionListener tag (x:treeselectionlistener) doesnt work, it
> >>>> says the component isnt a component tree. I tried to insert an
> >>>> actionListener like this #{sections.select} and created the method
> >>>> public void select(ActionEvent ae){..} in the sections bean, but it
> >>>> isnt called
> >>>> which should be the way to get the selected node using the tree2
> >>>> component?
> >>>>
> >>>> thanks in
> >
> >
> >
>
>