2

I have read many of the answers and pages but I cannot seem to find a situation similar to my own (I am guessing then, that my mistake is just a bone-head one).

I am simply trying to print out a list of items. c:forEach works... but ui:repeat does not (nor do any of my primefaces datagrids/tables).

<html xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:composition template="/templates/pageLayout.xhtml">
        <ui:define name="windowTitle">Manage my Worklists</ui:define>
        <ui:define name="pageContent">

            <h:outputStylesheet library="css" name="puradmin-style.css"  />

            <h:form id="manage-worklist" prependId="false">
                <br/>
                <c:forEach items="#{manageWorklistBean.givenAccessList}" var="friend">
                    <h:outputText value="* #{friend.receivingUser.name}" />
                    <br/>
                </c:forEach>
                <br/>
                <ui:repeat value="#{manageWorklistBean.givenAccessList}" var="friend">
                    <h:outputText value="* #{friend.receivingUser.name}" />
                    <br/>
                </ui:repeat>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

And here is my output:

* Friend One
* Friend Two
* Friend Three
*
*
*

Does anyone have any insight?

Peter Vanleeuwen
  • 327
  • 3
  • 10
  • 1
    So, given the three empty `*` lines, it thus properly iterates, but each `#{friend.receivingUser.name}` prints nothing, right? What appserver impl/version? What JSF impl/version? What if you print `#{friend}` instead of `#{friend.receivingUser.name}`? What if you give `` a different `var` name than the `` one, e.g. `var="_friend"` with `#{_friend}`? I can't reproduce your problem with Mojarra 2.1.12 on Tomcat 7.0.27, provided that backing bean and model code is written properly according standard idioms. – BalusC Aug 29 '12 at 14:10
  • Thank you so much! These were great suggestions. I was able to solve my problem in seconds. In my full page.. I have the var="friend" in two different components (a little lazy I know). I'm using Mojarra 2.1.6 and Glassfish 3.1.2 – Peter Vanleeuwen Aug 29 '12 at 14:27
  • You're welcome. I already guessed something like that, but the code provided so far would impossibly cause that (surely your `var="friend"` would be elsewhere in another JSF iterating component). I posted an answer. – BalusC Aug 29 '12 at 14:30

1 Answers1

1

Given the three empty * lines, the iteration thus works flawlessly, but each item as represented by the var attribute couldn't be resolved for some reason. One of the possible causes is a naming conflict in the var attribute in the EL scope during view render time, most likely caused by using another JSF iterating component in the same view which also uses the same var attribute name. Giving it a different and unique name should fix the problem, as confirmed in the comments of the question.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555