I simply need to perform a very basic for cycle in JSF/ICEFaces, basically rendering column numbers
Something like the following pseudo-code
for(int i=0; i<max; i++)
{
<td>#{i}</td>
}
the <c:forEach> tag iterates over collections, but I don’t want to make my backing bean more complex returning a stupid collection of integers.
Do you know a shorter and smarter way?
Thank you
The
<ui:repeat>tag is what you should really use. The JSTL tags operate outside of the JSF Lifecycle. Cay Horstman has a JSF coursewhich discusses this fact: ui:repeat and HandlingVariable-Length Data.
There are a couple of solutions below which demonstrate some flexibility. You could do something like this:
The maximum number of rows is determined by a a
<ui:parameter>namedmax. This is not required, but does demonstrate flexibility. Alternatively you could use something like:The backing bean code is the following: