rich:tree issue
alfrescian May 2, 2011 10:49 AMHi all,
I have a strong problem with component rich:tree.
I have the following in a XHTML page:
{code:xml}
<rich:simpleTogglePanel id="mgmt" switchType="client" label="#{msg.committeeshome}"
headerClass="gremienheader headText" >
<h:form>
<rich:tree id="tree" nodeSelectListener="#{companyHomeTreeBean.doSelect}" ajaxSubmitSelection="true" iconLeaf="../images/folder_open_blue.png"
icon="../images/folder_open_blue.png"
switchType="client" preserveModel="none" >
<rich:recursiveTreeNodesAdaptor roots="#{companyHomeTreeBean.srcRoots}" var="item" nodes="#{item.children}" >
<rich:treeNode ajaxSubmitSelection="true">
<a4j:commandLink value="#{item.label}" action="#{committeeLinkBean.committeeTreeLinkAction}" >
<f:param name="navision" value="#{committee.navisionId}"/>
</a4j:commandLink>
</rich:treeNode>
</rich:recursiveTreeNodesAdaptor>
</rich:tree>
</h:form>
</rich:simpleTogglePanel>
{code}
the tree is renderd, but whenerver i click the link on node the whole tree is reloaded and this take to much time, because i receive data from a database connected via hibernate. i don't know how to avoid this strang behavior.
Here is my 2 java Beans companyHomeTreeBean(session scoped), and the data model Bean: CommitteSubNode:
{code}public class CompanyHomeTreeBean {
/**
*
*/
private static final Logger sLogger = Logger.getLogger(CompanyHomeTreeBean.class);
List<CommitteeSubNode> companyHomeNodes;
private TreeDataModel treeDataModel;
private DAOFactory daoFactory;
private ArrayList<CommitteeSubNode> srcRoots;
public ArrayList<CommitteeSubNode> getSrcRoots()
{
if(this.srcRoots==null){
CommitteeDAO committeeDao=this.getDaoFactory().getCommitteeDao();
CommitteeHierachieDAO committeeHierachieDao=this.getDaoFactory().getCommitteeHierachieDao();
this.srcRoots= new ArrayList<CommitteeSubNode>();
ArrayList<CommitteeHierachie> rootCommittees=(ArrayList<CommitteeHierachie>)committeeHierachieDao.findFlatCommittees();
if(rootCommittees!=null){
for(CommitteeHierachie hr:rootCommittees)
{
if(hr!=null){
String navID=hr.getChildNo();
Committee committee= committeeDao.findById(navID);
if(committee!=null){
String label= committee.getDescription();
CommitteeSubNode subNode = new CommitteeSubNode(label,navID);
subNode.setCommitteeDao(committeeDao);
subNode.setCommitteeHierarchieDao( committeeHierachieDao);
synchronized(srcRoots){
this.srcRoots.add(subNode);
Collections.sort(srcRoots);
}
}
}
}
}
}
return srcRoots;
}
{code}
{code}
public class CommitteeSubNode implements Serializable,Comparable<CommitteeSubNode> {
private static final long serialVersionUID = -6279996348722156328L;
private static final Logger sLogger = Logger.getLogger(CommitteeSubNode.class);
private String label;
private String nodeId;
private String navisionId;
private String contentType;
private String description2;
ArrayList<CommitteeSubNode> children;
private CommitteeHierachieDAO committeeHierarchieDao;
private CommitteeDAO committeeDao;
public CommitteeSubNode(String label, String navisionId)
{
this.label = label;
this.navisionId = navisionId;
}
public String getNodeId()
{
return nodeId;
}
public void setNodeId(String nodeId)
{
this.nodeId = nodeId;
}
public void setChildren(ArrayList<CommitteeSubNode> subChildren)
{
this.children=subChildren;
}
public ArrayList<CommitteeSubNode> getChildren()
{
//System.out.println(" Navision Id: "+this.getNavisionId());
if(this.navisionId!=null)
{
WebApplicationContext appContext =
(WebApplicationContext)FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
sLogger.info("ApplicationContect: "+appContext.getBean("daoFactory").toString());
this.children= new ArrayList<CommitteeSubNode>();
DAOFactory daoFactory= (DAOFactory) appContext.getBean("daoFactory");
ArrayList<CommitteeHierachie> committeeLinks= (ArrayList<CommitteeHierachie>)daoFactory.getCommitteeHierachieDao().findChildrenCommittees(this.getNavisionId());
sLogger.info("List size: "+committeeLinks.size());
sLogger.info("Van ID in recursion: "+this.getNavisionId());
{
for(CommitteeHierachie hr1: committeeLinks){
String committeeNo= hr1.getChildNo();
Committee com=daoFactory.getCommitteeDao().findById(committeeNo);
if(com!=null){
String label= com.getDescription();
CommitteeSubNode subNode= new CommitteeSubNode(label,committeeNo);
// CommitteeSubNode ab= new CommitteeSubNode("Arbeitsbereich "+label,null);
synchronized(children){
this.children.add(subNode);
// this.children.add(ab);
Collections.sort(children);
}
}
}
}
}
return children;
}
{code}
please any clue is urgent.
private String nodeId;
private String navisionId;
private String contentType;
private String description2;
ArrayList<CommitteeSubNode> children;
private CommitteeHierachieDAO committeeHierarchieDao;
private CommitteeDAO committeeDao;
public CommitteeSubNode(String label, String navisionId)
{
this.label = label;
this.navisionId = navisionId;
}
public String getNodeId()
{
return nodeId;
}
public void setNodeId(String nodeId)
{
this.nodeId = nodeId;
}
public void setChildren(ArrayList<CommitteeSubNode> subChildren)
{
this.children=subChildren;
}
public ArrayList<CommitteeSubNode> getChildren()
{
//System.out.println(" Navision Id: "+this.getNavisionId());
if(this.navisionId!=null)
{
WebApplicationContext appContext =
(WebApplicationContext)FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
sLogger.info("ApplicationContect: "+appContext.getBean("daoFactory").toString());
this.children= new ArrayList<CommitteeSubNode>();
DAOFactory daoFactory= (DAOFactory) appContext.getBean("daoFactory");
ArrayList<CommitteeHierachie> committeeLinks= (ArrayList<CommitteeHierachie>)daoFactory.getCommitteeHierachieDao().findChildrenCommittees(this.getNavisionId());
sLogger.info("List size: "+committeeLinks.size());
sLogger.info("Van ID in recursion: "+this.getNavisionId());
{
for(CommitteeHierachie hr1: committeeLinks){
String committeeNo= hr1.getChildNo();
Committee com=daoFactory.getCommitteeDao().findById(committeeNo);
if(com!=null){
String label= com.getDescription();
CommitteeSubNode subNode= new CommitteeSubNode(label,committeeNo);
// CommitteeSubNode ab= new CommitteeSubNode("Arbeitsbereich "+label,null);
synchronized(children){
this.children.add(subNode);
// this.children.add(ab);
Collections.sort(children);
}
}
}
}
}
return children;
}