You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Bill Dudney <bd...@mac.com> on 2005/07/20 15:13:08 UTC

Re: [Myfaces-user] how to use TreeSelectionListener in a tree

Hi Alexandre,

Sorry that I can't answer your question but I wanted to redirect you  
to the new home of MyFaces on http://myfaces.apache.org.

I've cc'd the user list which is very active and can probably answer  
you question quickly.

Thanks for using MyFaces!

TTFN,

-bd-
On Jul 20, 2005, at 7:02 AM, Alexandre Cuvillier wrote:

> hello I am new to JSF
> I am using the tree component from myfaces.
> The problem is that I don't know how to get the Id of the node  
> where I am clicking.
> With an actionListener I always get the id of the last branch  
> deployed.
> With the component x:treeSelectionListener I call a class implement  
> TreeSelectionListener. And normaly the method valueChanged is callled.
> And It is not working. It is alwys the constrctors how is called.
> Here is my code, If someone find a mistake or can help me ...
>
> public class lienRepartitionListener implements TreeSelectionListener{
>
> private DefaultTreeModel treeModel;
>
>
> public lienRepartitionListener(){
> super();
> this.init();
> }
>
> private void init(){
>
> System.out.println("init");
>
> RepartitionTreeTable t =new RepartitionTreeTable();
>
> this.treeModel = t.getTreeModel();
> }
>
> public void valueChanged(TreeSelectionEvent event)
> {
>
> System.out.println("entre listener");
>
> }
> }
>
> jsf page
>
> <x:tree id="planComptableTree" value="#{treeTable.treeModel}"
> var="treeItem"
> styleClass="tree"
> nodeClass="treenode"
> headerClass="treeHeader"
> footerClass="treeFooter"
> rowClasses="a, b"
> columnClasses="col1, col2"
> selectedNodeClass="treenodeSelected"
> expandRoot="#{treeTable.expandRoot ne 0}">
> <x:treeSelectionListener  
> type="com.bull.crnpc.analytique.lienRepartitionListener"/>
>
> <x:treeColumn>
> <f:facet name="header">
> <h:outputText value="" />
> </f:facet>
> <h:outputText value="#{treeItem.numero}" rendered="# 
> {treeItem.numero ne'0'}" styleClass="compte"/>
> </x:treeColumn>
> <h:column>
> <f:facet name="header">
> <h:outputText value="" />
> </f:facet>
> <h:outputText value="#{treeItem.description}" rendered="# 
> {treeItem.numero ne'0'}" styleClass="compte"/>
> </h:column>
>
> <%--modification d'un compte --%>
> <h:column>
> <f:facet name="header">
> <h:outputText value="" />
> </f:facet>
> <h:commandLink action="go_plan"
> actionListener="#{treeTable.selectCompte}">
> <h:outputText id="compteModifId" value="#{treeItem.numero}" />
> <h:graphicImage value="images/modif.gif" rendered="# 
> {treeItem.numero ne '0'}"/>
> </h:commandLink>
> </h:column>
>
> <h:column>
> <f:facet name="header">
> <h:outputText value="" />
> </f:facet>
> <h:commandLink action="plan_comptable.jsp" immediate="true"
> actionListener="#{repartitionListener.selectCompte}">
> <h:outputText id="compteModifId2" value="#{treeItem.numero}" />
> <f:param name="compteModifNum" value="#{treeItem.numero}"/>
> <h:outputText value="methode sur table" />
> <h:graphicImage value="images/modif.gif" rendered="# 
> {treeItem.numero ne '0'}"/>
> </h:commandLink>
> </h:column>
> <%--suppression d'un compte --%>
> <h:column>
> <f:facet name="header">
> <h:outputText value="" />
> </f:facet>
>
> <h:commandLink action="go_plan_2"
> actionListener="#{treeTable.supprimerCompte}"
> rendered="#{treeItem.terminal eq 1}">
>
> <h:outputText id="compteId" value="#{treeItem.numero}"  
> rendered="false"/>
> <h:graphicImage value="images/delete.gif" rendered="# 
> {treeItem.terminal eq 1}"/>
> </h:commandLink>
> </h:column>
> </x:tree>