Why would my data be available at build time but not at render time?

两盒软妹~` 提交于 2019-12-06 12:03:53

问题


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.



来源:https://stackoverflow.com/questions/12179672/why-would-my-data-be-available-at-build-time-but-not-at-render-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!