File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Variable number of columns within dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Variable number of columns within dataTable" Watch "Variable number of columns within dataTable" New topic

Variable number of columns within dataTable

Rory Evans

Joined: Feb 19, 2010
Posts: 18

On my backing bean, I have a list of Player objects. Each Player object has a list of Card objects.

On my jsf page, I want to display a dataTable with one row per Player and one column per Card. Since each player may have a different number of cards, I need to have a way of determining how many columns to create.

My initial idea was to use something like:

but this renders no columns at all (after reading around the subject, I understand why this is the case). Can anyone suggest a suitable alternative or workaround for the problem described above?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16883

You're not the first one to discover that the ui:repeat element doesn't work well in tables.

Your best bet, I think, is to bind the table itself to a backing bean and construct the columns in backing bean code. Or you could use the RichFaces DataGrid control.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: Variable number of columns within dataTable
jQuery in Action, 3rd edition