包含和 h:datatable 的递归

Recursion with include and h:datatable

我在尝试 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>

请注意,首先 include post var 等于一个列表。在第二个包含中,我试图使它等于另一个列表,我认为这就是导致问题的原因。我不知道为什么,也不知道如何解决。 附带说明一下,我使用的是 jstl c:if,但如果有另一个纯 jsf 解决方案,我会接受它。

我找到了一些解决方法,但我会让这个问题没有答案。

我没有使用 DataTable,而是使用 jsp 标签 forEach 并且它有效。

所以不是这个:

<h:dataTable var="post" value="#{postList}">

我有:

<c:forEach var="post" items="#{postList}">

我不知道为什么这行得通而 dataTable 不行。如果有人知道请展开。