• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Grid Control

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim! I have something to chew on for now. Happy holidays!
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic