14

When using something like

<h:panelGrid columns="1">
    <ui:repeat var="o" value="#{mybean.list}">
        <h:outputText value="#{o.text}"/>
    </ui:repeat>
</h:panelGrid>

with lets say 10 list entries I only get 1 row e.g.: one tr with 1 td whereas when I use c:forEach i get 10 (but c:forEach is in fact evil, it messes up everything with ajax)

I use mojarra 1.2 - is this a typical Mojarra bug which does not exist in the MyFaces implementation? Will it disappear in 2.x of the Mojarra releases?

blo0p3r
  • 6,790
  • 8
  • 49
  • 68
Toskan
  • 13,911
  • 14
  • 95
  • 185

1 Answers1

34

The output is fully as expected and specified. The <ui:repeat> is a render time tag, not a view build time tag like <c:forEach>. After building the view, <h:panelGrid> ends up with 1 child component (the <ui:repeat> itself), not with n <h:outputText> components like as with <c:forEach>.

You need a <h:dataTable> instead. It's designed for exactly this purpose.

<h:dataTable var="o" value="#{mybean.list}">
    <h:column>
        <h:outputText value="#{o.text}"/>
    </h:column>
</h:dataTable>

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555