2

我有richtree人口的代码。

这是 mainmenu.xhtml 由最简单的 Richtree 声明组成:

<rich:tree value="#{menu.stationNodes}" var="station">
    <rich:treeNode>
          <h:outputText value="#{station}" />
    </rich:treeNode>
</rich:tree>

这是java托管bean:

import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import zcore.zTreeNode;
import zejb.trees;

@ManagedBean(name="menu")
@SessionScoped
public class Menutree implements Serializable {

    @EJB
    private trees tb;

    private static final long serialVersionUID = 1333L;
    private  zTreeNode<String> stationNodes = new  zTreeNode<String> (); 
    public Menutree(){
     }

    @PostConstruct
    public void postConstruct() {

        **//BLOCK A
        stationNodes.setData("root");
        stationNodes.addChild(0, new zTreeNode<String>("jjhshjssd"));
        stationNodes.addChild(0, new zTreeNode<String>("jsddssdsddd"));
        stationNodes.addChild(1, new zTreeNode<String>("ggggggd"));
        // BLOCK A - END**

        **//BLOCK B
        //stationNodes=tb.LoadTree();
        // BLOCK B - END**
    }

    Getter and Setter here.....
}

下面是块 B 中调用的 EJB 的一部分:

public zTreeNode<String> LoadTree() {

        zTreeNode<String> stationNodes =new zTreeNode<String>() ;
        stationNodes.setData("root");
        stationNodes.addChild(0, new zTreeNode<String>("jjhshjssd"));
        stationNodes.addChild(0, new zTreeNode<String>("jsddssdsddd"));
        stationNodes.addChild(1, new zTreeNode<String>("ggggggd"));
        return stationNodes;

} 

如果我使用 Block A,那么一切正常。如果我使用 Block B,那么我的 Richtree 在页面上保持空白。我做错了什么?

谢谢你。

4

0 回答 0