I have a simple requirement: The number of columns of my <tr:table/>
is dynamic. I will have a list of objects, someBean.features
which will determine how many columns are rendered.
The following diagram should clarify my requirement.
In the code that I was given, there was usage of the JSTL <c:forEach/>
tag which obviously created problems when used in a JSF environment. They had done something like this:
<tr:table value="#{someBean.values}">
<tr:column headerText="Name">
<tr:outputText value="#{someBean.name}"/>
</tr:column>
<c:forEach var="col" items="#{someBean.features}">
<tr:column headerText="Column-#{col.id}">
<tr:outputText value="#{col.name}"/>
</tr:column>
</c:forEach>
</tr:table>
But when I profiled the above code, the method someBean.getValues
which is the input to the <tr:table/>
tag above was getting called several thousands of times rather than about 20. This - as I figured out - was due to the fact that <c:forEach/>
tag is a compile time tag where as <tr:*/>
are render time tags.
So, here's what I intend to do (replace <c:forEach/>
with <tr:iterator/>
:
<tr:table value="#{someBean.values}">
<tr:column headerText="Name">
<tr:outputText value="#{someBean.name}"/>
</tr:column>
<tr:iterator var="col" value="#{someBean.features}">
<tr:column headerText="Column-#{col.id}">
<tr:outputText value="#{col.name}"/>
</tr:column>
</tr:iterator>
</tr:table>
But, for some reason, the <tr:iterator/>
doesn't seem to like being placed inside a <tr:table/>
and it never gets executed.
Any solution, tips, guidelines will be greatly appreciated.
Oh and we're using JSF 1.1 with a MyFaces Trinidad 1.0.13 implementation.
Thanks.