views:

541

answers:

1

Is it possible to dynamically generate pairs of columns using RichFaces' rich:columns component? (Version 3.3.0)

Ideally, I'd like to generate something resembling the following:

+------+--------------+--------------+---------------
| Name |    1/2/09    |    2/2/09    | 3/2/09 (etc.)
+------+------+-------+------+-------+-----------
| .... | Time | Value | Time | Value |
+------+------+-------+------+-------+-------
| .... | Time | Value | Time | Value |

... that is, a single header cell per column-pair, with the two columns underneath. However, the combined header is not that important.

I've consulted the docs, and while they suggest that a colspan can (somehow) be used, they don't offer any examples.

Any help appreciated!

+2  A: 

Try the following. Have in mind that oneElementCollection should be a collection that contains just one row of an object DaysData, which has the List of days in it.

<rich:dataTable value="#{oneElementCollection}" var="daysData">

     <a4j:repeat value="#{daysData.days}" var="day">
         <rich:subtable value="#{day.infos} var="info">
             <f:facet name="header">
                <h:outputText="#{day.display}" />
             </f:facet>
             <rich:column>
                 <f:facet name="header">
                    <h:outputText="time" />
                  </f:facet>
             <h:outputText value="#{info.time}" />
           </rich:column>
             <rich:column>
                 <f:facet name="header">
                    <h:outputText="value" />
                  </f:facet>
             <h:outputText value="#{info.value}" />
           </rich:column>
         </rich:subtable>
     </a4j:repeat>

     </rich:subtable>
</rich:dataTable>
Bozho
+1. Use subtable for data. If there is a common pattern in (sub)columns names(properties) you can use facelets template that will generate appropriate header.
cetnar
I updated the table 'diagram' in my question. I have a time and value for each day, with the property name down the left-hand side.
harto
your case is strange :) check my update, and give feedback after you try it
Bozho