2017-01-17 1 views
0

この例はロールをリストし、各ロールに関連するグループとユーザーを表示します。各役割のツリーテーブルを表示するために使用データテーブルの行拡張Treetable

XHTML

 <p:column headerText="Designation"> 
      <h:outputText value="#{rl.designation}" /> 
     </p:column> 


      <p:rowExpansion> 
       <p:treeTable value="#{roleMB.root}" var="document"> 
        <p:column headerText="Designation"> 
        <h:outputText value="#{document}" /> 
        </p:column> 
       </p:treeTable> 
      </p:rowExpansion> 
</p:dataTable> 

CONTROLLER

方法。

あなたが各役割のリストGROUPEの生成をトリガrowToggleイベントが欠落している
public void createRoot(){ 
     List<AffectationRoleGroupe> groupesRole=new ArrayList<AffectationRoleGroupe>(); 
     for(Role rl:roles){ 

     root=new DefaultTreeNode("Root", null); 

     groupesRole=rl.getAffectationsRG(); 
     for(AffectationRoleGroupe a:groupesRole){ 
      System.out.println(rl.getDesignation()); 
      System.out.println(a.getGroupe().getDesignation()); 
      TreeNode node = new DefaultTreeNode(a.getGroupe().getDesignation(), root); 
     } 
    } 
+0

とは何ですか? –

答えて

0

まず:あなたの方法で

<p:ajax event="rowToggle" listener="#{managedBean.createRoot(role)}" update=":treeGroupe" /> 

<p:rowExpansion> 
    <p:treeTable id="treeGroupe" value="#{roleMB.root}" var="groupe"> 
     <p:column headerText="Designation"> 
      <h:outputText value="#{groupe.designation}" /> 
     </p:column> 
    </p:treeTable> 
</p:rowExpansion> 

第二に、あなたがhundlingている役割を渡す必要があり、その後、あなたが持っています役割のグループと、ツリーのノードを埋めるために:

public void createRoot(Role role){ 
    ...... 
} 

あなたはのtreeTableをhundleする方法を見ることができます:http://www.primefaces.org/showcase/ui/data/treetable/basic.xhtml