myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Galligan" <kgalli...@gmail.com>
Subject Re: forEach accesses 'items' collection multiple times
Date Thu, 05 Oct 2006 17:51:20 GMT
Once I swapped to ui:repeat, all the problems went away.

I saw the thing about not using forEach in the docs after I sent this.

Still, thought it was odd that it grabs the collection on each run.

Thanks,
-Kevin

On 10/3/06, Jeff Bischoff <jbischoff@klkurz.com> wrote:
> 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
> >
> >
> >
>
>
>

Mime
View raw message