I’m developing an application using jsf2 and facelets. In one of my views I try to display data from a database and I use two nested loops. The second loop uses a var which is an attribute of the var declared for the first loop.
But it’s not working.
Here is the relevant part of my code:
<ui:repeat value="#{MyBean.Vect}" var="item">
<h:outputText value="${item.attr}" /> <br />
<ui:repeat value="#{item.nestedtVect}" var="product" >
<h:outputText value="${product.name}" /> <br />
</ui:repeat>
</ui:repeat>
The first loop works but not both.
Are you sure
item.nestedtVectis not null and actually has items? Your Facelet seems to be correct at first sight.E.g. consider this minimal example:
Backing bean:
Facelet:
This Just Works™. You might want to put in an explicit test to see if your nested collection is empty or not:
p.s.
Unrelated to the question, but you might want to look at your naming.
MyBean.Vectis not a really good name, and neither isattrinitem.attr. Also, you seem to mix deferred and immediate syntax (#{}and${}) for no apparent reason.