title: How to display Parent and Child ( two different objects ) in treetable primefaces?
body: <p>I am using Treetable component to display parent and child objects. I can able to display the parent content by using <a href="http://www.primefaces.org/showcase/ui/treeTable.jsf" rel="nofollow">this tutorial.</a></p>
  
  <p>In my case, I am using two different objects to display the contents in the TreeTable component. Those objects are following.</p>
  
  <blockquote>
    <ol>
    <li><strong>University Detail</strong> - It is my parent Object. It contains (Id and Name of each university) as well as child colleges.</li>
    <li><strong>College Detail</strong> - It is my child Object. It contains (Id and Name) of each college.</li>
    </ol>
  </blockquote>
  
  <hr>
  
  <p><strong>UniversityDetail Class</strong></p>
  
  <pre><code>public class UniversityDetail implements Serializable {
  
      /**
       * serialVersionUID -   
       */
      private static final long serialVersionUID = 1L;
      /**
       * UniversityId -   
       */
      private Integer UniversityId;
      /**
       * UniversityName   -   
       */
      private String UniversityName;
      /**
       * CollegeDetail    -
       */
      private List&lt;CollegeDetail&gt; CollegeDetail   =   new ArrayList&lt;CollegeDetail&gt;();
  
      public Integer getUniversityId() {
          return UniversityId;
      }
  
      public void setUniversityId(Integer UniversityId) {
          this.UniversityId = UniversityId;
      }
  
      public String getUniversityName() {
          return UniversityName;
      }
  
      public void setUniversityName(String UniversityName) {
          this.UniversityName = UniversityName;
      }
  
      public List&lt;CollegeDetail&gt; getCollegeDetail() {
          return CollegeDetail;
      }
  
      public void setCollegeDetail(
              List&lt;CollegeDetail&gt; collegeDetail) {
          this.CollegeDetail = collegeDetail;
      }
  
  }
  </code></pre>
  
  <p><strong>College Detail</strong> </p>
  
  <pre><code>public class CollegeDetail implements Serializable{
  
      /**
       * CollegeId    -   
       */
      private Integer CollegeId;
      /**
       * CollegeName  -
       */
      private String CollegeName;
  
      public Integer getCollegeId() {
          return CollegeId;
      }
  
      public void setCollegeId(Integer CollegeId) {
          this.CollegeId = CollegeId;
      }
  
      public String getCollegeName() {
          return CollegeName;
      }
  
      public void setCollegeName(String CollegeName) {
          this.CollegeName = CollegeName;
      }
  
  }
  </code></pre>
  
  <hr>
  
  <p><strong>How to display these detail classes with the treetable component ? I dont know how to iterate the child elements(College Detail)</strong></p>
  
  <p>I have the following xhtml code to display the parent and child. I could render the parent detail. But I am failing to render the child class detail. Any help is much appreciated.</p>
  
  <pre><code>&lt;p:treeTable value="#{ManagedBean.root}" var="object" id="multiSelect"  
               selection="#{ManagedBean.selectedNodes}" selectionMode="checkbox"&gt;  
  
      &lt;f:facet name="header"&gt;  
          College Dropdown  
      &lt;/f:facet&gt;  
  
      &lt;p:column style="width:100px"&gt;  
          &lt;f:facet name="header"&gt;  
              University Name  
          &lt;/f:facet&gt;  
          &lt;h:outputText value="#{object.universityName}" /&gt;  
      &lt;/p:column&gt;  
  
      &lt;p:column style="display:none"&gt;  
          &lt;f:facet name="header"&gt;  
              University ID
          &lt;/f:facet&gt;  
          &lt;h:outputText value="#{object.universityId}" /&gt;  
      &lt;/p:column&gt;  
  
  &lt;/p:treeTable&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>ManagedBean</strong></p>
  
  <pre><code>RootTree = new CheckboxTreeNode("Root", null);
  for(int i =0 ; i&lt;CompanyDetail.size();i++) {
  UniversityDetail universityDetail   = UniversityDetail.get(i);
      List&lt;CollegeDetail&gt; collegeDetail   =   universityDetail.getCollegeDetail();
      TreeNode parent = new CheckboxTreeNode(universityDetail,RootTree);
      for(int j=0; j&lt;collegeDetail.size();j++) {
      TreeNode child = new CheckboxTreeNode(collegeDetail.get(j).getCollegeName(),collegeDetail.get(j), parent);                  
     }
  </code></pre>