AnsweredAssumed Answered

How to break from a nested gel:forEach loop?

Question asked by StevenJames on Jun 27, 2012
Latest reply on Jun 28, 2012 by StevenJames
Hi all,
I have a <gel:forEach> loop nested within a <core:while> loop. I need to break out from the <gel:forEach> loop and continue round the <core:while> loop. If I use <core:break/> then I am taken out of the <core:while> loop rather than the <gel:forEach> loop. Has anybody come across a work around for this?
The code sample below demonstrates this issue:
<gel:script xmlns:core="jelly:core"
<gel:parse var="groups">
        <group code="CTU">CTU Team</group>
        <group code="SWAT">SWAT Team</group>
        <group code="ADMIN">Admin Team</group>
        <group code="DEV">Developer Team</group>

<core:set var="theTest" value="true"/>
<core:while test="${theTest == true}">
    <gel:forEach select="$groups/groups/group" var="group">
        <gel:set var="code" select="$group//@code" asString="true"/>
        <core:if test="${code == 'ADMIN'}">
             <gel:set select="$groups/groups/group/@code" var="theTest" asString="true"/>
    <gel:out>Out of forEach!</gel:out>
<gel:out>Out of while!</gel:out>