You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Avaneesh Arora <av...@gmail.com> on 2005/05/14 19:50:04 UTC

Dynamic column counts in data tables.

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

Re: Dynamic column counts in data tables.

Posted by alex <de...@yahoo.co.nz>.
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