File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes data table list in a list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "data table list in a list" Watch "data table list in a list" New topic
Author

data table list in a list

Yasir Qureshi
Greenhorn

Joined: Apr 26, 2006
Posts: 24
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

Joined: Nov 06, 2008
Posts: 8
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.


Harish Govind
Yasir Qureshi
Greenhorn

Joined: Apr 26, 2006
Posts: 24
I want to display list A and also list B which is contained by list A, in the same data table.
Marius Snyman
Greenhorn

Joined: May 04, 2006
Posts: 14
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.
 
jQuery in Action, 2nd edition
 
subject: data table list in a list
 
Similar Threads
rendering each child t:tree node in seperate column in panel grid
how to display list of objects in turn each object contains one more list using jsf2.0 datatable?
Dynamic datatable in jsf
Mixing dataTable with selectOneRadio
Error while displaying validation message for inputText generated dynamically in rich:dataTable