This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use TreeSelectionListener in a tree ?  RSS feed

 
cualexfra cuvi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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>
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!