jQuery in Action, 3rd edition
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
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: 17410

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: Variable number of columns within dataTable
It's not a secret anymore!