为什么我的数据在构建时可用,而在渲染时不可用? [英] Why would my data be available at build time but not at render time?

查看:74
本文介绍了为什么我的数据在构建时可用,而在渲染时不可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了许多答案和页面,但似乎找不到与自己类似的情况(当时我想,我的错误只是一个愚蠢的错误).

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).

我只是想打印出项目清单. c:forEach可以工作...但是ui:repeat不能(我的任何primefaces数据网格/表也都不会).

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>

这是我的输出:

*朋友一号
*朋友二
*朋友三
*
*
*

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

有人有什么见识吗?

推荐答案

给出三个空的*行,因此迭代可以完美地进行,但是var属性表示的每个项目在某些情况下都无法解析原因.可能的原因之一是在视图渲染期间EL作用域中的var属性中的命名冲突,最可能是由在同一视图中使用另一个JSF迭代组件(也使用相同的var属性名称)引起的.如问题评论中所确认的,给它一个不同且唯一的名称应该可以解决该问题.

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.

这篇关于为什么我的数据在构建时可用,而在渲染时不可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆