• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to use TreeSelectionListener in a tree ?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello 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 utputText value="" />
</f:facet>
<h utputText value="#{treeItem.numero}" rendered="#{treeItem.numero ne'0'}" styleClass="compte"/>
</x:treeColumn>
<h:column>
<f:facet name="header">
<h utputText value="" />
</f:facet>
<h utputText value="#{treeItem.description}" rendered="#{treeItem.numero ne'0'}" styleClass="compte"/>
</h:column>

<%--modification d'un compte --%>
<h:column>
<f:facet name="header">
<h utputText value="" />
</f:facet>
<h:commandLink action="go_plan"
actionListener="#{treeTable.selectCompte}">
<h utputText 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 utputText value="" />
</f:facet>
<h:commandLink action="plan_comptable.jsp" immediate="true"
actionListener="#{repartitionListener.selectCompte}">
<h utputText id="compteModifId2" value="#{treeItem.numero}" />
<f aram name="compteModifNum" value="#{treeItem.numero}"/>
<h utputText 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 utputText value="" />
</f:facet>

<h:commandLink action="go_plan_2"
actionListener="#{treeTable.supprimerCompte}"
rendered="#{treeItem.terminal eq 1}">

<h utputText id="compteId" value="#{treeItem.numero}" rendered="false"/>
<h:graphicImage value="images/delete.gif" rendered="#{treeItem.terminal eq 1}"/>
</h:commandLink>
</h:column>
</x:tree>
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic