jsfjstlrichfacesseam

c:forEach.items getting repetitively called


Environment: Seam, Richfaces

The following code snippet causes the method getUsers to be called multiple times, how do I avoid this in my application so that it gets called only once.

<c:forEach items="#{userHome.getUsers()}" var="_user">
</c:forEach>

Solution

  • A rule of thumb is to avoid <c: tags when using JSF (unless you are sure they work as expected)

    Here you'd better replace it with:

    <a4j:repeat value="#{userHome.users}" var ="_user">
    </a4j:repeat>
    

    (or <ui:repeat> if using facelets)

    PS: I guess getUsers() is JBoss' EL-extension, but I'd suggest not to use its extended features unless really needed.