wood burning stoves 2.0*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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
Author

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

Anup Mulik
Greenhorn

Joined: Dec 18, 2010
Posts: 7
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.....


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.

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

Regards,
Brendan.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create Dyanamic columns for dataTable in JSF.....
 
Similar Threads
randomness in test data
Passed!
Passed By Reference?
Showing a List of Maps in a dataTable
JSF-DWR Components not adding to viewroot