Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

h:dataTable and handling multiple collections

 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Here's a scenario I need help with...

I am trying to populate a table...this table has 3 columns...
1. Name of a property
2. Value of Property from entity1
3. Value of Property from entity2

The backing bean has a propertiesList which is an arraylist and this in turn has 2 property lists
1. propertyList1
2. propertyList2
which in turn are arraylists.

each property in above lists is a Property object with the name value pair...

How do i achieve this scenario using h:dataTable...

<h:dataTable id="outerTable"
| var="z"
| value="#{propertiesList}">

then what? how do I iterate through both the propertyist1 and list2 and display the values as requested above?...Lets assume the order of the names of attributes are in sync for both the lists
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, there are a few options.

1. Create a UI Bean that will store the values you want in the table in a single collection structure. This would require more code and you looping through your two lists to combine them into one big list.

2. Use a third party JSF datatable that supports sub-tables.

3. Nest jsf datatables, the inner datatable using the var from the outertable to get to the inner list.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic