Menu

#10 multiple if tags are not working for next iteration

1.0
wont-fix
nobody
None
2020-02-21
2014-01-24
sushant
No

I have just created two if statement tags within a foreach tag. For the first iteration everything goes fine but for the next iteration second if statement doesnt get executed. When i debug the code i can see that second if condition is process for the expression evaluation.

<jt:forEach items="${values}" var="value" indexVar="index">
    <jt:if test="${index==0}">
        <jt:style style="bottom-border-color:${color}"/>
    </jt:if>
    <jt:if test="${index>0}">
        <jt:style style="bottom-border-color:${color2}">
    </jt:if>

</jt:forEach>

Discussion

  • Randy Gettman

    Randy Gettman - 2014-01-30
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,9 +1,10 @@
    -i have just created two if statement tag within foreach tag. for the first iteration everything goes fine but for the next iteration second if statement doesnt get executed. When i debug the code i can see that second if condition is process for the expression evaluation.
    -<jt:forEach items="${values}" var="value" indexVar="index">
    -    <jt:if test="${index==0}">
    -        <jt:style style="bottom-border-color:${color}"/>
    -     </jt:if>
    -    <jt:if test="${index>0}">
    -        <jt:style style="bottom-border-color:${color2}">
    -    </jt:if>
    +I have just created two if statement tags within a foreach tag. For the first iteration everything goes fine but for the next iteration second if statement doesnt get executed. When i debug the code i can see that second if condition is process for the expression evaluation.
    +
    +    <jt:forEach items="${values}" var="value" indexVar="index">
    +        <jt:if test="${index==0}">
    +            <jt:style style="bottom-border-color:${color}"/>
    +        </jt:if>
    +        <jt:if test="${index>0}">
    +            <jt:style style="bottom-border-color:${color2}">
    +        </jt:if>
     </jt:forEach>
    
     
  • Randy Gettman

    Randy Gettman - 2014-01-30

    I have edited your post to format your JETT code so that it shows up and isn't interpreted as HTML.

    However, it's unclear in which cells each tag is located. Please post an example template spreadsheet that demonstrates the problem.

    You may also place the condition inside the JEXL expression itself, and avoid a <jt:if> tag, something like this:

    <jt:style style="bottom-border-color:${(index == 0) ? color : color2}"/>
    
     
  • Randy Gettman

    Randy Gettman - 2014-05-09
    • status: open --> wont-fix
     
  • Randy Gettman

    Randy Gettman - 2014-05-09

    Won't fix; not enough information to determine the problem.

     
  • Byoungchul, Kim

    Byoungchul, Kim - 2020-02-21

    <jt:foreach var="csItem" items="${csList.subData}" copyright="true">
    <jt:if test="${csItem.data02 == 'IMAGE'}">
    <jt:image rows="1" pathname="${csItem.data01}" cols="1">
    </jt:image></jt:if>
    <jt:if test="${csItem.data02 != 'IMAGE'}">
    ${csItem.data01}
    </jt:if>
    </jt:foreach>

    It is not work.!

     

Log in to post a comment.