incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rogers Reilly <>
Subject Re: Table with dynamic number of columns
Date Wed, 01 Nov 2006 18:49:40 GMT
Hi Dan,

I've wrestled with this quite a bit, and I think the last is your only 
option.  Change

"#{row.list.size() >= 2}"


"#{row.list.size >= 2}"

and I think El will do just fine.  Otherwise you can define some static 
El function (not too painful if you're using Facelets already, I find) 
like so:  rendered="#{df:staticFuncName(row)}".

In general, you can't stick anything that's not an <tr:column> under 
<tr:table>.  I tried extending Table to accomodate a <ui:repeat> object 
(Facelets tag), but it didn't quite work.  It's possible a <c:forEach> 
Facelets tag would work since it doesn't insert a new component in the 
view tree, just stamps out x number of children (in this case 
<tr:column>s), but I had trouble changing the # of columns once I'd 
created a Table.  It seems Table initializes its # of columns on 
construction, so that changing it will yield an ArrayIndex error.

All the way around, stamping out all possible columns and then 
controlling display with "rendered" is easiest.  Another possibility is 
Tomahawk extensions, which I believe do have a dynamic-column 
<t:columns> component.

Hope this helps-

Daniel Hannum wrote:

>Is it possible to create a tr:table with a dynamic number of columns? I
>have a table backed by a list of objects A, in the typical way. Each row
>pulls out some fixed properties of A, but A also contains a list of B's.
>I want each of the B's to be some additional columns. Don't worry, I can
>guarantee that all the A's have the same number of B's, so each row of
>the table will have the same number of columns, but I don't know what
>that number is before runtime.
>I tried the iterator tag, but you aren't allowed to put it directly
>under <table>. I tried making a column tag that contained an iterator
>and N sub-columns. The results were unpredictable and I got a
>ArrayIndexOutOfBounds. Before I looked too deeply into that, maybe I'm
>just not supposed to do that. I don't know.
>Another option might be to put the maximum number of columns in the
>table, and set rendered=false for the ones I won't use. But that's a lot
>for EL. The second column would have rendered="#{row.list.size() >= 2}",
>which I don't even think is allowed in EL.
>Thanks for any help you can offer.

View raw message