[英]List embedded in another list with JSF 2, PrimeFaces and JSTL
On a Facelets page I travel a list to display data in a p:dataTable
(a PrimeFaces component). 在Facelets页面上,我浏览了一个列表以在
p:dataTable
(PrimeFaces组件)中显示数据。 This list itself contains another list that I travel using a c:forEach
(JSTL). 该列表本身包含另一个我使用
c:forEach
(JSTL)访问的列表。
The problem is that the data for the list that c:forEach
should handle does not appear. 问题是
c:forEach
应该处理的列表数据没有出现。 When I access a specific element it works well, but not in a c:forEach
. 当我访问特定元素时,它可以很好地工作,但是在
c:forEach
却不能。
Is it not possible to use an inner loop variable embedded in another loop? 是否不可能使用嵌入在另一个循环中的内部循环变量?
Here's the page's code: 这是页面的代码:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<body>
<ui:composition template="./template_utilisateur.xhtml">
<ui:define name="content">
<h:form prependId="false" id="form">
<p:growl id="growl" showDetail="true"/>
<p:dataTable id="carsTable" var="car" value="#{histCommController.lc}" rowKey="#{car.id}"
selectionMode="single" >
<f:facet name="header">
Expand rows to see detailed information
</f:facet>
<p:column style="width:4%">
<p:rowToggler/>
</p:column>
<p:column style="width:48%">
<f:facet name="header">
id
</f:facet>
<h:outputText value="#{car.id}" />
</p:column>
<p:column style="width:48%">
<f:facet name="header">
date envoi
</f:facet>
<h:outputText value="#{car.dateEnvoi}" />
</p:column>
<p:rowExpansion id="expanssion">
<h:panelGrid id="display" columns="2" cellpadding="4" style="width:300px;"
styleClass=" ui-widget-content grid">
<h:outputText value="Model:" />
<h:outputText value="#{car.id}" />
<h:outputText value="Year:" />
<h:outputText value="#{car.etat}" />
<h:outputText value="Manufacturer:" />
<h:outputText value="#{car.dateEnvoi}" />
<h:outputText value="Color:" />
<h:outputText value="#{car.dateLivraisonRecommande}" />
<h:outputText value="Fichiers : " />
<h:outputText value="::::::::::::" />
<h:outputText value="Fichiers 1 : " />
<h:outputText value="#{car.listFichiers.get(0).nom}" />
<c:forEach var="jjjjj" items="#{car.listFichiers}">
<h:outputText value="nom fichier 1 : " />
<h:outputText value="#{jjjjj.nom}" />
</c:forEach>
</h:panelGrid>
</p:rowExpansion>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
The problem occurs because you are mixing so-called build-time
and render-time
constructs. 发生问题是因为您混合了所谓的
build-time
render-time
构造和render-time
构造。
build-time
happens first, and everything that happens there can not make use of things that don't exist until render-time
, which happens after. build-time
首先发生,并且在那里发生的所有事情都不能利用直到render-time
之后才存在的事物。
In your case, the JSTL forEach
is build-time, while the car
var is made available by the render-time dataTable
. 在您的情况下,JSTL
forEach
是构建时的,而car
var由render-time dataTable
。 The solution is to use a render-time construct for the inner looping. 解决方案是将渲染时构造用于内部循环。 The best candidate for this is
ui:repeat
. 最佳选择是
ui:repeat
。
See also 也可以看看
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.