• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to display data in a table dynamically?

 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Need to display data in a table - no of columns are fixed, and rows may vary based on the data available in DB.
Display tables in horizontally and 2 tables per row. If it exceeds 3 it should display in next row

sample format to display attached in attachment,


Using JSF 2 & richfaces 4.0
Please share the sample code to achieve the above scenario.



DynamicTable.png
[Thumbnail for DynamicTable.png]
 
Tim Holloway
Bartender
Posts: 18413
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We're not a "do my homework" resource, but I'd probably use a panelGrid as the outer container in most cases like this. If the number of cells containing inner tables is variable, you'd probably have to go with nested dataTables, where the outer table had as its row model 2 columns each containing a DataModel for the inner tables.

And, since JSF doesn't handle nested dataTables very cleanly at the moment, it would be pretty gnarly.
 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Retriving data from DB and populating data inside <c:forEach >
currently it is displaying vertically.

Need to display in horizontally.
Any other specific tags to do the above?
 
Tim Holloway
Bartender
Posts: 18413
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL is a bad mix with JSF. It's better to use ui:repeat.

However, no, the best you could do is put a ui:repeat in a 2-column h:panelGrid and emit a series of h:dataTables.

It would still be messy, however, since nested tables, as I said before are not something that JSF presently handles very cleanly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!