• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

data table list in a list

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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}">
<h:outputText 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.
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic