Velocity
  1. Velocity
  2. VELOCITY-658

$velocityHasNext does not work in nested loops

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6, 1.6.1
    • Fix Version/s: 1.7
    • Component/s: Engine
    • Labels:
      None

      Description

      With this test case:

      assertEvalEquals("test1 (a1;a2;a3)-test2 (a1;a2;a3)-test3 (a1;a2;a3)-test4 (a1;a2;a3)",
      "#foreach ($value in $list)$value (#foreach ($val in $list2)$val#if( $velocityHasNext );#end#end)#if( $velocityHasNext )-#end#end");

      Velocity 1.6.1 (or current head) fails because the "hasNext" flag status of the outer foreach loop gets overwritten by the nested foreach loop. To fix this we need to save the status of the hasNext flag in Foreach directive just like we save the value of the counter.

      This bug is related to VELOCITY-657 but is a separate bug.

        Issue Links

          Activity

          Jarkko Viinamäki created issue -
          Jarkko Viinamäki made changes -
          Field Original Value New Value
          Attachment velocity-hasNext-bug.patch [ 12396805 ]
          Jarkko Viinamäki made changes -
          Link This issue is related to VELOCITY-600 [ VELOCITY-600 ]
          Jarkko Viinamäki made changes -
          Link This issue is related to VELOCITY-657 [ VELOCITY-657 ]
          Jarkko Viinamäki made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Jarkko Viinamäki made changes -
          Status Resolved [ 5 ] Reopened [ 4 ]
          Resolution Fixed [ 1 ]
          Jarkko Viinamäki made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Fix Version/s 1.7 [ 12313453 ]
          Mark Thomas made changes -
          Workflow jira [ 12449166 ] Default workflow, editable Closed status [ 12551662 ]
          Mark Thomas made changes -
          Workflow Default workflow, editable Closed status [ 12551662 ] jira [ 12552538 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Jarkko Viinamäki
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development