rich:tree 来创建动态树遇到的问题

这个星期一直在用jsf来做一个动态树,画面刚载入的时候加载第一二层,点击第一层的结点时加载第二三层。逻辑实现了,但是画面上的箭头没有相应的事件属性,无法实现它和后台绑定。
画面代码:
<h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
   <rich:tree id="pagefresh"  style="width:300px" nodeSelectListener="#{tree1bean.nodeload}" reRender="pagefresh" ajaxSubmitSelection="true"  switchType="client" value="#{tree1bean.treeNode}" var="item" >
   </rich:tree>
</h:panelGrid>

后台代码:
package org.jboss.test.main;

import java.util.List;

import javax.ejb.Remove;
import javax.persistence.EntityManager;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.richfaces.component.UITree;
import org.richfaces.event.NodeExpandedEvent;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;

@Scope(ScopeType.SESSION)
@Name("tree1bean")
public class Tree1Bean{
private Tree tree;
private TreeNode treenode = null;
private List<Tree> onloadtree;
private List<Tree> onloadtree1;
private String selectnodesql = "from Tree t where t.parentid = ? order by t.id";
private int linkid;
private int flg;
private int parentid;

@In("entityManager")
private EntityManager em;

private void firstNode(int id,TreeNode node){
        onloadtree = em.createQuery(selectnodesql).setParameter(1, id).getResultList();
        for (int i=0;i<onloadtree.size();i++){
        TreeNodeImpl nodeImpl = new TreeNodeImpl();
        nodeImpl.setData(onloadtree.get(i).getName());
        node.addChild(new Integer(onloadtree.get(i).getId()), nodeImpl);
        secondeNode(onloadtree.get(i).getId(),nodeImpl);
       }
}
    private void secondeNode(int id,TreeNode node){
        onloadtree1 = em.createQuery(selectnodesql).setParameter(1, id).getResultList();
        for (int i=0;i<onloadtree1.size();i++){
        TreeNodeImpl nodeImpl = new TreeNodeImpl();
        nodeImpl.setData(onloadtree1.get(i).getName());
        node.addChild(new Integer(onloadtree1.get(i).getId()), nodeImpl);
       }
    }

public TreeNode getTreeNode(){
if (treenode == null){
treenode = new TreeNodeImpl();
parentid = 0;
firstNode(parentid,treenode);
}
return treenode;
}

public void nodeload(NodeSelectedEvent event){
UITree tree = (UITree) event.getComponent();
linkid = Integer.parseInt(tree.getRowKey().toString());
firstNode(linkid,tree.getModelTreeNode());
}


public int getLinkid() {
return linkid;
}
public void setLinkid1(int linkid) {
this.linkid = linkid;
}


@Remove
public void destroy() {
// TODO Auto-generated method stub

}
}

希望有碰到过相同问题的有经验的朋友帮忙解决。多谢。

你可能感兴趣的:(jboss,Richfaces,ejb,JSF,seam)