No tree element available ot row key not set.. while expand
chennaraoeda Apr 13, 2009 11:40 AMHi All ,
I want to expand a node from out side tree(fpr example data table)
When i programatically expanding tree node by creating ListRowKey
I am getting No tree element available ot row key not set..
But I am able to expnadAll and collapse All....
Here is sample application(sorry for Typo errors if any, i typed all the conent, I cannot copy the code from my system)..
I tried the following inputs :
2
2:3
2:3:4
It seems problem with ListRowKey,
when i give input 2:3 , when i made debug messages in UITree queueExandMethod,
getting RowKey as 2_:3(adding _)....
kindly provide any correct path for the following tree structure..
A is root node id:2
B, C are children to A with ids(3,4 respectively)
D is child of C with id 5...
Tthanks in advance....
Page...
tree.xhtml.....
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<p>Sample Tree</p><br/>
<h:form>
<rich:tree id="myTree"
toggleOnClick="true"
switchType="server"
ajaxSubmitSelection="true"
value="#{myTreeBean.myTreeData}" var="compRow"
ajaxSingle="true"
binding="#{myTreeBean.tree}
acceptedTypes="anyType"
iconLeaf="/images/tree/tree.gif"
icon="/images/tree/tree.gif"
nodeFace="anyType">
<rich:treeNode id="tNode" ajaxSingle="true" type="anyType" >
<h:outputText value="#{compRow}" />
</rich:treeNode>
</rich:tree>
<a4j:commandLink action="#{myTreeBean.expandAll}" ajaxSingle="true" reRender="myTree">Expand All</a4j:commandLink>
<br>
<h:outputText value="Enter the path to expand" />
<h:inputText value="#{myTreeBean.path}" />
<a4j:commandButton action="#{myTreeBean.expandPath}" reRender="myTree" value="Submit " />
</h:form>
</ui:composition>
Faces-Config Entry------
<managed-bean> <managed-bean-name>myTreeBean</managed-bean-name> <managed-bean-class>org.richfaces.MyTreeBean</managed-bean-class> <managed-bean-scope>reques t</managed-bean-scope> <managed-bean>
-------Managed bean Code---------
package org.richfaces;
import java.io.IOException;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.event.FacesEvent;
import org.richfaces.component.UITree;
import org.richfaces.component.UITreeNode;
import org.richfaces.event.NodSelectedEvent;
import org.richfaces.model.ListRowKey;
public class MyTreeBean{
UITree tree;
private String path;
//---setter and getters.. for path
//......
public TreeImpl getMyTreeData(){
TreeImpl root=new TreeImpl();
root.setData("Root Node");
TreeImpl nodeA=new TreeImpl();
nodeA.setCompId(2L);
nodeA.setData("Company A");
TreeImpl nodeB=new TreeImpl();
nodeB.setCompId(2L);
nodeB.setData("Company B");
TreeImpl nodeC=new TreeImpl();
nodeC.setCompId(2L);
nodeC.setData("Company C");
TreeImpl nodeD=new TreeImpl();
nodeD.setCompId(2L);
nodeD.setData("Company D");
root.addChild(2L,nodeA);
nodeA.addChild(3L,nodeB);
nodeA.addChild(4L,nodeC);
nodeC.addChild(3L,nodeD);
return root;
}
private UIComponent getTree(){
return this.tree;
}
public void setTree(UIComponent tree){
this.tree=(UITree)tree;
}
public String expandAll(){
try{
this.tree.queueExpandAll();
}
catch(IOException exp){
exp.printStackTrace();
}
return null;
}
public String expandPath(){
String pathtoExpand=getPath();
if(pathToExpand!=null && pathToExpand.trim().length()!=0){
try{
this.tree.queueNodeExpand(new ListRowKey(pathToExpand));//getting exception here
//Also tried this
// TreeState state=(TreeState) this.tree.getComponentState();
//state.expandNode(this.tree,new ListRowKey(pathToExpand)); Getting excetion here
}
catch(IOException exp){
throw new FacesException(exp);
}
return null;
}
}
---------TreeImpl ----
Tree Impl is simple VO with
private Long compId;
private String compNme;
--setters and getters....
I used same web.xml of demo examples at
http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf
Thanks.....
chenna