0

I want to render a panelGrid with a fixed number of columns but elements are loaded from a list. The code should be as follows:

<h:panelGrid columns="3">
    <h:outputText value="Header 1"/>
    <h:outputText value="Header 2"/>
    <h:outputText value="Header 3"/>

    <ui:repeat value="#{bean.collection}" var="obj">
        <p:panel>
            <h:outputText value="#{obj.value}"/>
        </p:panel>
    </ui:repeat>
</p:panelGrid>

The problem is this code is not rendering as I expected, because all panels are enclosed in the first TD generated by panelGrid, and I want a row break every 3 elements. It seems all repeat block is executed prior the rendering. I'm sure I can obtain this behaviour. What I'm doing wrong?

Thanks

Erik Schierboom
  • 16,301
  • 10
  • 64
  • 81
Carlos
  • 41
  • 5
  • 1
    possible duplicate of [ui:repeat and h:panelGrid](http://stackoverflow.com/questions/8945544/uirepeat-and-hpanelgrid) – BalusC Jan 26 '13 at 13:06

1 Answers1

1

ui:repeat is a component and it is part of the component tree. To create what you are planning try using tag handler c:forEach instead.

<c:forEach items="#{bean.collection}" var="obj">
  <p:panel>
    <h:outputText value="#{obj.value}"/>
  </p:panel>
</c:forEach>
partlov
  • 13,789
  • 6
  • 63
  • 82
  • You should not use `${}`, but `#{}`, otherwise bean won't be auto-created if it does not exist in scope yet. – BalusC Jan 26 '13 at 13:05
  • Hm, you made it worse. Now the other `#{}` has become a `${}`. You should never use `${}` in JSF2, but exclusively `#{}`. Using `${}` in JSTL tags in JSF pages is only necessary in JSF 1.x / JSTL 1.1 because `#{}` wasn't supported in JSTL tags (but you'd need to auto-create beans yourself if necessary). See also http://stackoverflow.com/questions/4812755/difference-between-jsp-el-jsf-el-and-unified-el/4812883#4812883 – BalusC Jan 26 '13 at 13:07