Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Grid Control  RSS feed

 
Ken Rubin
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new to JSF. Could someone please point me in the right direction in how I may create a grid or table, which for a particular cell could have multiple items created dynamically, like buttons or links.
I see that there are tables, gridpanels and CSS Style sheets. If anyone could recommend a general approach, example or tutorial, it would be extremely helpful and greatly appreciated!

Thank you,

Ken
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest variable-element grid component in the basic JSF armoury is the dataTable. Unlike the panelGrid, which has a static number of elements, the dataTable can have a variable number of rows, based on the number of rows in the DataModel object that backs it.

A variable number of columns is a bit trickier, since the original JSF spec didn't cover this. Back then, you had to resort to brute force, binding the actual container element to a backing bean, then putting login in the backing bean to dynamically construct UICOmponent tree elements and attach them in their proper places. Not something to do just for idle amusement.

In JSF2 (or JSF 1 with Facelets added on), you can use the Facelets ui:repeat tag to do a variable number of elements and avoid the platform-specific Java code.

Some extension tagsets, such as RichFaces also have elements that can handle multiple sub-components relatively easily as well. I just discovered (and used) the "columns" tag that permits the number of columns in their extended dataTable to be set dynamically, in fact. It made short work of what I'd expected to be a long project.
 
Ken Rubin
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim! I have something to chew on for now. Happy holidays!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!