I have a list of objects, "think draggable panels" that need to be rendered on the screen. Each of these Panels has it's own material it needs to render inside it. My initial thought was to do something like
<ui:repeat value="#{bean.widgets} var="widget">
<p:panel binding="#{widget.contents}/>
</ui:repeat>
Now this doesn't work probably for many reason. One i know of is that the "var" is only request scope. So, whereas i can access the values of fields within my "widget" java object, I can't directly call a method to bind my panel to.
Could anyone provide direction to take?
Currently running PrimeFaces 3.2 | GlassFish 3.1.2 | Mojarra 2.1.6
The binding
attribute is evaluated during view build time, while the <ui:repeat var>
attribute is evaluated during view render time, so it's indeed null
at the point the <p:panel>
is discovered and built.
Use JSTL <c:forEach>
instead of <ui:repeat>
(and fix the missing quote):
<c:forEach items="#{bean.widgets}" var="widget">
<p:panel binding="#{widget.contents}/>
</c:forEach>
This way you're also really generating physically multiple <p:panel>
components instead of only one which get rendered multiple times.
Using JSTL may in turn however have other caveats, depending on the total picture which isn't clear from the question. See also JSTL in JSF2 Facelets... makes sense?