Why would my data be available at build time but n

2020-07-27 04:15发布

问题:

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?

回答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.