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

          Hide
          Jarkko Viinamäki added a comment -

          Thanks. Marking this as resolved.

          Show
          Jarkko Viinamäki added a comment - Thanks. Marking this as resolved.
          Hide
          Byron Foster added a comment -

          Applied, thanks

          Show
          Byron Foster added a comment - Applied, thanks
          Hide
          Jarkko Viinamäki added a comment -

          Testcase and a patch that fixes this bug.

          Show
          Jarkko Viinamäki added a comment - Testcase and a patch that fixes this bug.

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development