Kevin,

There are lots of issues in JSF 1.1 with collection tags like c:forEach. To avoid running into these, I use forEach sparingly in my app. When I do use it, I also use c:out rather than h:outputText. See [1] for some info.

[1] http://java.sun.com/developer/technicalArticles/J2EE/jsp_21/

Regards,

Jeff Bischoff
Kenneth L Kurz & Associates, Inc.

Kevin Galligan wrote:
I'm using the 'forEach' tag in a page.  When I ran a debugger against
my code, it looks like the forEach is grabbing the collection in the
'items' attribute each time it runs through the loop.  I'd think it
would only do this once.  Here's the code...

<c:forEach items="#{sharedPortalsSpecialtySponsorProgramMixer.sponsorProducts}"
var="sponsorProduct">
    <tr>
        <td style="border-bottom: 0px">
            <h:outputText value="#{sponsorProduct.title}"/>
        </td>
    </tr>
</c:forEach>

Each row in 'sponsorProducts' causes a call to grab the whole list.
If I take the 'h:outputText' out of the cell and just dump out some
regular text (ie. don't access the 'sponsorProduct'), it only grabs
the list once.

Facelets version '1.1.11'.  I can make this "work" by caching the list
rather than having it hit the db each time, but it seems really odd.
Like I have something configured wrong.

Thanks in advance,
-Kevin





Reply via email to