I have lists of objects named allAlbums
and allPhotos
. Now, I want to show all photos in each album, so I used the following method.
My code is:
<s:iterator value="allAlbums">
<s:iterator value="allPhotos">
<s:if test="%{#allAlbums.albumid == #allPhotos.albumid}">
<s:property value="photourl"/>
</s:if>
</s:iterator>
</s:iterator>
But, it is not working. Any suggestion what am I doing wrong?
Make sure that both of your object have appropriate getters/setters, then you can use feature provided by OGNL called projection.
<s:iterator value="allAlbums" var="album">
<s:iterator value="allPhotos.{? #this.albumid == #album.albumid}">
<s:property value="photourl"/>
</s:iterator>
</s:iterator>