【发布时间】:2015-10-28 23:45:48
【问题描述】:
我在尝试recursively include pages 时遇到了一些麻烦。问题是所有的包含实际上都发生了,但是 h:dataTable 发生了一些事情,所以第二个包含的数据表内容没有显示出来。我猜这个问题来自与 var post 并发本身。它可以在没有数据表的情况下工作。
所以我从 page.xhtml 调用 post_view2.xhtml 的包含:
<ui:include src="/template/includes/post_view2.xhtml" >
<ui:param name="postList" value="#{watchThread.listeFirstPosts}"></ui:param>
<ui:param name="count" value="8"></ui:param>
</ui:include>
计数设置为 8。
这是 post_view2.xhtml:
<ui:composition xmlns=....>
<h:dataTable var="post" value="#{postList}" styleClass="fullWidth">
<h:column>
#{post.posts.size()} <!-- gives a size higher than 0 -->
<h:outputText value="#{watchThread.sanitize(post.content)}"/>
<c:if test="${count gt 0}">
<ui:include src="/template/includes/post_view2.xhtml">
<ui:param name="postList" value="#{post.replies}"></ui:param>
<ui:param name="count" value="${count-1}"></ui:param>
</ui:include>
</c:if>
</h:column>
</h:dataTable>
</ui:composition>
请注意,在第一个包含 post var 时,它等于一个列表。在第二个包括我试图使它等于另一个列表,我认为这就是导致问题的原因。我不知道为什么,也不知道如何解决。
附带说明一下,我使用的是 jstl c:if,但如果有另一种纯 jsf 的解决方案,我会接受 primefaces。
【问题讨论】:
-
“仅在我第一次调用时包含”是什么意思?下次您重新加载(导航到相同的)页面时,它不会显示嵌套表格,对吧?
-
@Guillermo 不,我措辞错误。所有的包含实际上都发生了,但是 h:dataTable 发生了一些事情,使得它不会显示第二个包含的数据表内容。我希望我把它清理干净了。