2

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:selectBooleanCheckbox value="#{inscricao.credenciamento}" />
         </rich:column>
    </a4j:repeat>
</rich:column>
Igor
  • 1,397
  • 3
  • 24
  • 56
  • Why you specify label attribute for rich:column? It is needed only for drag and drop of extendedDataTable. – Andrey Aug 17 '11 at 12:28
  • I assume you're using RichFaces 4.0? RichFaces 3.3 had a `` for exactly this purpose. It's indeed not available anymore in RF 4.0, but it's planned for RF 4.1. So, I'd suggest: stay tuned... – BalusC Aug 17 '11 at 13:18
  • already tryed using rich:columns, but without success... using richface 3.2. and changed to 3.3. to test rich:columns... but also "works" at 3.2. – Igor Aug 17 '11 at 13:52

1 Answers1

0

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.

Andrey
  • 6,526
  • 3
  • 39
  • 58
  • Well, when i put the c:set and h:outputText as you said into c:forEach into the column, it shows the number "4"... so its seems like he is already initialized.. – Igor Aug 17 '11 at 12:17
  • Using c:forEach is only correct way to have dynamic columns in rich:dataTable, using ui:repeat or a4j:repeat will not work appropriately. Use c:forEach approach and then debug your code. For example check how tree is being build. Debug ForEachHandler class and see how items are evaluated, etc. (look for these lines: srcVE = this.items.getValueExpression(ctx, Object.class); src = srcVE.getValue(ctx);) – Andrey Aug 17 '11 at 12:30