Primefaces Tree [p:tree]初始化ManagedBean并在呈现为false时调用getter

时间:2014-07-16 10:45:57

标签: jsf primefaces

你好,

Primefaces p:tree初始化ManagedBean并调用Getter方法,即使我使用rendered=false也是如此。

的facelet:

<h:body>
    <h:form >
        <p:outputLabel value="#{mBeanOne.beanOnetxt}"/><br/>
    </h:form>

    <h:panelGroup rendered="false" layout="block" >
        <p:tree value="#{treeBasicView.root}" id="xeon" var="node" rendered="false">
            <p:treeNode rendered="false">
                <h:outputText value="#{node}" rendered="false"/>
            </p:treeNode>
        </p:tree>
    </h:panelGroup>
</h:body>

ManagedBean:

@ManagedBean(name="treeBasicView")
@ViewScoped
public class BasicView implements Serializable {

    private TreeNode root;

    @PostConstruct
    public void init() {
        System.out.println("BasicView - PostConstruct");
        root = new DefaultTreeNode("Root", null);
        TreeNode node0 = new DefaultTreeNode("Node 0", root);
        TreeNode node1 = new DefaultTreeNode("Node 1", root);

        TreeNode node00 = new DefaultTreeNode("Node 0.0", node0);
        TreeNode node01 = new DefaultTreeNode("Node 0.1", node0);

        TreeNode node10 = new DefaultTreeNode("Node 1.0", node1);

        node1.getChildren().add(new DefaultTreeNode("Node 1.1",node1));
        node00.getChildren().add(new DefaultTreeNode("Node 0.0.0",node00));
        node00.getChildren().add(new DefaultTreeNode("Node 0.0.1",node00));
        node01.getChildren().add(new DefaultTreeNode("Node 0.1.0",node01));
        node10.getChildren().add(new DefaultTreeNode("Node 1.0.0",node10));
        root.getChildren().add(new DefaultTreeNode("Node 2",root));
    }

    public TreeNode getRoot() {
        System.out.println("getRoot");
        return root;
    }
}

我当前的Primefaces版本是3.5,JSF是2.1.13

0 个答案:

没有答案