2

I'm having some troubles trying to recursively include pages. The problem is that all the include actually take place but there is something going on with the h:dataTable that makes it so the second included datatable content isn't displayed.. I'm guessing the problem comes from the var post being concurrent with itself. It works without the datatable.

So from a page.xhtml I'm calling an include for 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> 

Count is set to 8.

This is 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>

Notice that at the first include the post var is equal to a list. On the second include I'm trying to make it equal to another list and I think that is what is causing the problem. I don't know why nor how to solve it. On a side note I'm using jstl c:if but if there is another solution that is pure jsf, primefaces included I'd take it.

Community
  • 1
  • 1
Ced
  • 15,847
  • 14
  • 87
  • 146
  • What do you mean with *"include only for the first time I call it"*? The next time you reload (navigate to the same) page it doesn't show nested tables, right? – Guillermo Aug 07 '15 at 06:09
  • @Guillermo no, I worded it wrongly. All the include actually take place but there is something going on with the h:dataTable that makes it so the second included datatable content isn't displayed. I hope I cleared it up. – Ced Aug 07 '15 at 12:09

1 Answers1

1

I found a bit of a workaround but I'll let the question as unanswered.

Instead of using DataTable I'm using jsp tag forEach and it works.

so instead of this:

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

I have :

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

I don't know why this works and dataTable doesn't. If anyone knows please expand.

Ced
  • 15,847
  • 14
  • 87
  • 146