gcubed

Gel Script Exit

Discussion created by gcubed Champion on Feb 7, 2014
Latest reply on Feb 7, 2014 by gcubed

Is there any clean way to exit a gel script?

For example, I excute a query and find that I didn't get any results.  Want I want to do is:

<core:if test="${resultSet.getRowCount() == 0}">
    <core:exit/>
</core:if>

 

I figured out a work around using <core:break> but i just want to see if I am missing something:

<gel:script
    xmlns:core="jelly:core"
    xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <gel:out>Test Gel ForEach Script Exit</gel:out>
    <!--
    Set scriptBreak to contain one value in an array
    Wrap our script in a loop so we can use break to exit cleanly
    -->
    <core:set var="scriptBreak" value="[1]" />
    <core:forEach var="dummy" items="${scriptBreak}">
        <core:set var="i" value="0" />
        <gel:out>Start with i set to ${i}</gel:out>
        <core:set var="i" value="${i+1}" />
        <core:if test="${i == 0}">
            <gel:out>We should not see this false test output</gel:out>
        </core:if>
        <core:if test="${i == 1}">
            <gel:out>We should see this true test output</gel:out>
            <core:break />
        </core:if>
        <gel:out>We should not see this because of the break tag</gel:out>
    </core:forEach>
</gel:script>

 

V/r,

Gene

Outcomes