To identify which node was pressed add an actionListener (that implements javax.faces.event.ActionListener) to your commandLink (in your jsp). In the actionListener you can then retrieve the commandLink selected:

HtmlCommandLink link = (HtmlCommandLink)event.getComponent();

Then if you do:

link.getClientId(faceContext);

you'll get the currently selected node id that is under the form 0:0 where 0 is the root

Emmanuel

On 8/29/05, MarcV <[EMAIL PROTECTED]> wrote:
You need in fact a actionlistener to do it:

<f:facet name="document">
                  <h:panelGroup>
                    <h:commandLink immediate="true"

styleClass="#{sbNavigatorTreeBean.nodeSelected ?
'documentSelected':'document'}"

actionListener="#{sbNavigatorTreeBean.setNodeSelected}"
                              action="" sbNavigatorTreeBean.menuAction}">
                      <h:graphicImage value="images/tree/document.png"
style="border='0'"/>
                      <f:param name="paramMenuAction"
value="#{node.identifier}" />
                      <h:outputText value="#{node.description}"/>
                    </h:commandLink>
                  </h:panelGroup>
                </f:facet>

The param will provide the id of the node when it is clicked

2005/8/29, Felix Japs <[EMAIL PROTECTED]>:
> Hi,
>
> thanks for the quick response. My Problem ist not to create and display a
> tree but to identify which node was clicked by the user. I think I need the
> "binding-attribute". But perhaps there ist another way?
>
> bye,
>
> felix
>
>
> > For the Client side...
> >
> > <x:tree2 value="#{ sbNavigatorTreeBean.treeData}"
> >                       id="client-tree"
> >                               var="node"
> >                               varNodeToggler="t"
> >                               showRootNode="false"
> >                               preserveToggle="true">
> >
> >
> > and in the NavigatorBean...
> >
> > public class NavigatorTreeBean {
> >
> >       private TreeNode treeData;
> >
> >       public NavigatorTreeBean (){
> >                       TreeNodeBase folderNode;
> >                       TreeNodeBase personNode;
> >
> >                       treeData = new TreeNodeBase("person",
> > "Menu", false);
> >
> >               // construct a set of fake data (normally your
> > data would come from a database)
> >
> >               // populate Fixed Elements portion of the tree
> >                       personNode = new
> > TreeNodeBase("separator", "Menu", false);
> >               treeData.getChildren().add(personNode);
> >
> >                       personNode = new TreeNodeBase("person",
> > "Instruments", false);
> >               personNode.getChildren().add(new
> > TreeNodeBase("document", "View","goIssueSearch", true));
> >               personNode.getChildren().add(new
> > TreeNodeBase("document",
> > "Create","#{sbNavigationBean.goIssueCreation}", true ));
> >               personNode.getChildren().add(new
> > TreeNodeBase("document", "Quick
> > Create","#{sbNavigationBean.goIssueCreation}", true));
> >               (...)
> >
> > 2005/8/29, Felix Japs <[EMAIL PROTECTED]>:
> > > Hi,
> > >
> > > can someone show me an example how to bind data to the
> > tree2 component?
> > >
> > > <x:tree2 id="serverTree2" value="#{treeBacker.treeData}" var="node"
> > > varNodeToggler="t" clientSideToggle="false" binding="??????">
> > >
> > > thanks for help,
> > >
> > > bye
> > >
> > > Felix Japs
>
>


--
A+,
MarcV.

Reply via email to