It's not a secret anymore!
The moose likes JSF and the fly likes How to create Dyanamic columns for dataTable in JSF..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to create Dyanamic columns for dataTable in JSF....." Watch "How to create Dyanamic columns for dataTable in JSF....." New topic

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

Anup Mulik

Joined: Dec 18, 2010
Posts: 8

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.....

SCJP 5,SCWCD 5,SCBCD 5,SCDJWS in progress.....
Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218

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

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: How to create Dyanamic columns for dataTable in JSF.....
It's not a secret anymore!