2013-03-23 32 views
0

我在一個xhtml中使用p:tree,它被動態地包含到另一個xhtml的tabview中。當我們更改標籤時,樹擴展不起作用。我無法通過單擊節點旁邊的圖標來展開樹。Primefaces p:動態加載時的樹

注意:或者它不起作用。只有在index.xhtml中的tabview的dynamic =「true」和cache =「false」時纔會出現問題。完整的代碼如下,使用該場景很容易重現。

由於我在我的項目的許多地方使用p:tree,如果這是一個錯誤,我要求任何人提供至少一個臨時解決方法。我已經在primefaces論壇發佈了這個。我在Tomcat 7.0中使用Primefaces 3.5 JSF

的index.xhtml

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:p="http://primefaces.org/ui"> 
    <h:head></h:head> 
    <h:body> 
     <p:tabView dynamic="true" cache="false"> 
     <p:tab title="One"> 
      <ui:include src="/one.xhtml" /> 
     </p:tab> 
     <p:tab title="two" /> 
     </p:tabView> 
    </h:body> 
</html> 

one.xhtml

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:p="http://primefaces.org/ui"> 
    <h:head> 
    </h:head> 
    <h:body> 
     <p:tree widgetVar="treeStructure" value="#{treeBean.root}" var="node" selectionMode="single" id="tree"> 
      <p:treeNode> 
       <h:outputText value="#{node}" /> 
      </p:treeNode> 
     </p:tree> 
    </h:body> 
</html> 

TreeBean.java

@ManagedBean 
@SessionScoped 
public class TreeBean { 
    private TreeNode root; 

    public TreeNode getRoot() { 
     return root; 
    } 
    public void setRoot(TreeNode root) { 
     this.root = root; 
    } 
    public TreeBean() { 
     root = new DefaultTreeNode("Root", null); 
     TreeNode node0 = new DefaultTreeNode("Node 0", root); 
     TreeNode node00 = new DefaultTreeNode("Node 0.0", node0); 
    } 
} 
+0

在瀏覽器中檢測到任何javascript錯誤嗎? – Jitesh 2013-03-24 20:49:07

+0

不,正如我在請求處理以及嘗試擴展時在螢火蟲中發現的那樣。 – RAMSY 2013-03-25 02:22:58

回答

0

找到解決方案。這很簡單明顯,但掙扎。刪除<h:head></h:head>標籤one.xhtml這是沒有必要的,並重新加載所需的js文件已加載和非常可用。總是在主頁面上保留<h:head></h:head>標籤。這裏是index.xhtml