Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create Dyanamic columns for dataTable in JSF.....

 
Anup Mulik
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In JSF i am displaying records in datatable,to my datatable a list (name :displayList ) is passed which contains object's.

My displayList is populated from a method populateDisplayListFromResultset().

populateDisplayListFromResultset() method interacts calls getDisplayResultset() .

getDisplayResultset() method interacts with databse using JDBC and call a procedures which returns diff cursor's depending upon the selection criteria(ticket type) passed as a parameter.

The ResultSet is iterated and depending upon the cursors out put and ticket type a respective object is formed which and then added into the displayList of populateDisplayListFromResultset() method and that displayList is passed as a value to dataTable

<h:dataTable value="#{TicketProcessingBean.displayList }" var="itrDisplayList ">

My issue is that i am having different types of Ticket Object depending on the ticket type having different attributes,so in my procedure diff select cursors output are returned depending on ticket type, so my TicketProcessingBean.displayList list will be holding different Ticket Objets depending on the Ticket Type.

So each time when i am dispalying dataTable , i want columns to be dynamic as per my current Ticket Object in displayList list.

In short i want columns of my dataTable to be dynamic for dispalying ticket details of different types.

Please help me out for the above.....
 
Brendan Healey
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can do this with the PrimeFaces p:dataTable component, you'll need the latest
version 2.2RC2.

http://www.primefaces.org/showcase/ui/datatableDynamicColumns.jsf

Regards,
Brendan.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18156
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If PrimeFaces is not an option, you can also do this in a backing bean. Just bind the table control to the bean and instantiate "HtmlColumn" objects, adding them as children to the HtmlDataTable object.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic