开发者

Using foreach into jsf / xhtml [duplicate]

开发者 https://www.devze.com 2023-03-28 18:14 出处:网络
This question already has answers here: JSTL in JSF2 Facelets... makes sense? (3 answers) Closed 2 years ago.
This question already has answers here: JSTL in JSF2 Facelets... makes sense? (3 answers) Closed 2 years ago.

Well,

I array a dataTable where i must have some dynamic columns.... So im using dataTable... Like the code above:

<rich:dataTable value="#{query.dataModel}" var="inscricao">
            <rich:column label="My List">
                <f:facet name="header">
                    <h:outputText value="My List" />
                </f:facet>
                <h:outputText value="#{query.presencas.size()}" />
            </rich:column>

                        <c:forEach var="presenca" items="${query.presencas}">
                            <rich:column label="Presença">
                <f:facet name="header">
                        <h:outputText value="Presença" />
                </f:facet>
                <h:outputText value="testing" />
                </rich:column>
                        </c:forEach>
</rich:dataTable>

Well, my problem is that my foreach is not working. The column "My List" shows the number of element i have in the list correctly... But when i try iterating it into c:forEach its not working...

I've already tryed using:

xmlns:c="http://java.sun.com/jstl/core"

and this other one:

xmlns:c="http://java.sun.com/jsp/jstl/core"

But withotu success... Also tryed using ui:repeat like this:

<ui:repeat value="#{query.presencas}" var="presenca">
    <f:facet name="header">
        <h:outputText value="#{presenca.id}" />
    </f:facet>
</ui:repeat>

But also not worked.

Someone know what can be the problem or some another way to iterate a list?

I saw that if i use an a4j:repeat INTO a column, it recognize my column inside the a4j:repeat. Otherwise, if i remove the column outside a4j:repeat it doesnt work...

<rich:column label="Presenças" title="teste"  >
    <a4j:repeat value="#{query.presencas}" var="presenca">
         <rich:column label="Presenças" title="teste"  >
        <f:facet name="header">
            <h:outputText value="Presença" />
        </f:facet>
        <h:selectBooleanCh开发者_如何学编程eckbox value="#{inscricao.credenciamento}" />
         </rich:column>
    </a4j:repeat>
</rich:column>


Value of output text component (value="#{query.presencas.size()}") is evaluated on render response phase. Value of forEach tag handler (items="${query.presencas}") is evaluated on build tree. You are using different symbols in EL to differentiate that ($ and #). It seems that query.presencas is not initialized on build tree. You can check that evaluating count on build tree:

<c:set var="count" value="${query.presencas.size()}"/>
<h:outputText value="#{count}"/>

To build dynamic number of columns you can use c:forEach (as you do), items attribute will be evaluated on build tree (so for example inscricao var is not available when items value is being evaluated). Using ui:repeat it will not work since RichFaces components (dataTable, tabPanel and others) does not handle that.

0

精彩评论

暂无评论...
验证码 换一张
取 消