2011-10-08 87 views
0

我是JSF新手,所以這是我的第一個項目。 我的IDE是netbeans的7.0.1,2.1.1鑽嘴魚科和primefaces 2.2.1無法查看primefaces樹

我通過http://www.primefaces.org/showcase/ui/tree.jsf 使用的樹例子,而我設法用其他faclets從素(例如號碼:按鈕) 的樹不爲我工作(空白屏幕) 有人可以請我解釋我做錯了什麼?

感謝

<?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; 
} 

}

回答

1

我想這是因爲你沒有@ManagedBean標註在TreeBean類