Dynamic column counts in data tables.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic column counts in data tables.

Avaneesh Arora
Hi All,

I find it very surprising that all the JSF Datamodels use the concept of data for each row yet in the JSP page, one specifies each column individually, so one needs to know how many columns are there in each data row.

How can I create a reporting template (Like a reporting framework for different database tables)  where the number of columns are not known in advance? How do I go about generating the information and then render it?

Since the <c:for>  tags do not work inside of the datatable, this seems even more difficult than it should be. Otherwise it would have been easy to do
Could I use Scriplets for looping?  Do they work inside of <h:dataTable>?

If I know that of all the tables in my application, I will have maximum 50 columns, I can go set a column count flag in my backing bean and any column count > Column_count in model has a rendered="false", but that is not a good solution. Or is it one?

How else could I create a dynamic table with number of columns unknown at design time?

Any suggestions?

Thanks,
Avaneesh
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic column counts in data tables.

alex-3
Avaneesh Arora wrote:

> How can I create a reporting template (Like a reporting framework for
> different database tables)  where the number of columns are not known
> in advance? How do I go about generating the information and then
> render it?

Maybe the <x:columns> tag would be helpfull for you. This allows you to
render an unknown number of columns and works with a var similar to
dataTable. It must be nested in a dataTable.

If this doesn't fit your needs or the implementation causes problems to
you, then go and bind the dataTable via the biinding-attribute to a
property in a backing bean, where you then create the whole table and
return it.  <x:dataTable binding="#{backingBean.dataTable}" />
However, this approach is very hard and frustrating.. I know, what I am
talking about, have to use this one :(
And the MVC model is a bit broken with that approach.

Rgds
Alex