开发者

unable to view primefaces tree

I am new to JSF so this is my first project. My IDE is netbeans 7.0.1, Mojarra 2.1.1 and primefaces 2.2.1

I used the tree example via http://www.primefaces.org/showcase/ui/tree.jsf While I manage to use other faclets from prime (for example p:button) the tree is not working for me(blank screen) Can someone can please explained me what did I do wrong ?

Thanks

 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0    Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:p="http://primefaces.prime.com.tr/ui"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">
<f:view contentType="text/html"> 
<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body>
    <h:form>
        <p:tree value="#{treeBean.root}" var="node">
            <p:treeNode>
                <h:outputText value="#{node}" /> 
            </p:treeNode>
        </p:tree>
    </h:form>
</h:body>
</f:view>

 package org.primefaces.examples.view;

import javax.faces.bean.SessionScoped;
import org.primefaces.model.TreeNode;
import org.primefaces.model.DefaultTreeNode;


public class TreeBean {

private TreeNode root;

public TreeBean() {
    root = new DefaultTreeNode("Root", null);
    TreeNode node0 = new DefaultTreeNode("Node 0", root);
    TreeNode node1 = new DefaultTreeNode("Node 1", root);
    TreeNode node2 = new DefaultTreeNode("Node 2", 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);
    TreeNode node11 = new DefaultTreeNode("Node 1.1", node1);

    TreeNode node000 = new DefaultTreeNode("Node 0.0.0", node00);
    TreeNode node001 = new DefaultTreeNode("Node 0.0.1", node00);
    TreeNode node010 = new DefaultTreeNode("Node 0.1.0", node01);

    TreeNode node100 = new DefaultTreeNode("Node 1.0.0",开发者_运维技巧 node10);
}

public TreeNode getRoot() {
    return root;
}

}


I think it's because you don't have @ManagedBean annotation in your TreeBean class

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜