Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

data table list in a list

 
Yasir Qureshi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using datatable to display a list of object say A that has another list of object lets say B in it, This is how my object looks:

Class A{
private String name;
private B[] b;
}

How can I display such an object in datatable? I am out of clue how to display List of Object B.

Thanks.
 
Harish Govind
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Yasir could you please more specific on your requirement. Do you want to display total list A as a datamodel (in which list b also exists) or just display list A elements excluding list B from it and show list B as datamodel whenever any action is done on user.
 
Yasir Qureshi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to display list A and also list B which is contained by list A, in the same data table.
 
Marius Snyman
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Yasir Qureshi:
I want to display list A and also list B which is contained by list A, in the same data table.


In you backing add two HTMLDatatables
private HtmlDataTable dataTableA;
private HtmlDataTable dataTableB;
private List ListA ;
private List ListB ;


On your web page link:
<h:dataTable id="itemsA" bindings="#{bbean.dataTableA}" value="bbean.ListA">
<h:dataTable id="itemsB" bindings="#{bbean.dataTableB}" value="bbean.ListB" rendered="false">

Add the entries of ListA to dataTableA
Add A commandLink to a column in dataTableA which calls a method in the backing bean:

ex:
<h:commandLink action="#{bbean.selectDetail}">
<hutputText value="Show Detail"/>
</h:commandLink>

in the backin bean method set the rendering for tableB to true
public void selectDetail(){
ListB = ListA.ListBData
ListB.setRendered(true)
}

You will then display your data as a sort of Master/Detail record on the web page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic