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

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

问题描述

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

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天全站免登陆