Search code examples
jett

How to use <jt:span /> tag with nested <jt:forEach></jt:forEach>?


I got parse error exception when I try to use with nested . Can Span tag use along with nested loop?

enter image description here

     Subunit                                                 |                                                    Fiber                                              |   IL   |    RL    | XX |    RL
-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+--------+----------+----+-----------------------------------
<jt:span factor="${wo.serialNumbers.size}" value="${wo.id}"/>|<jt:forEach items="${workOrders}" var="wo"><jt:forEach items="${wo.serialNumbers}" var="sn">${sn.fiber}|${sn.il}|${sn.rl_a}| XX |${sn.rl_b}</jt:forEach><jt:forEach>

Solution

  • Yes, a jt:span tag can be used along side a jt:forEach, even if it's nested. The error you're getting is most likely because you're referencing the variable wo in the jt:span tag on the left from outside of the jt:forEach loop it's defined in, which is the cells to the right.

    If you plan to have multiple span tags, one for each work order, then include it in the body of the outer jt:forEach tag. Move the outer jt:forEach tag to the beginning of the leftmost cell.

                    Subunit                                                                                 |                        Fiber                               |   IL   |    RL    | XX |    RL
    --------------------------------------------------------------------------------------------------------+------------------------------------------------------------+--------+----------+----+-----------------------------------
    <jt:forEach items="${workOrders}" var="wo"><jt:span factor="${wo.serialNumbers.size}" value="${wo.id}"/>|<jt:forEach items="${wo.serialNumbers}" var="sn">${sn.fiber}|${sn.il}|${sn.rl_a}| XX |${sn.rl_b}</jt:forEach><jt:forEach>
    

    This will make wo be in scope in the outer jt:forEach tag and produce the spans for the inner jt:forEach tags.