Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-109

failed to call overloaded method in foreach loop when item changes class type

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3-rc1
    • Fix Version/s: None
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC
    • Bugzilla Id:
      13637

      Description

      1 create a class with two overloaded methods like
      public class Helper {
      public String getFoo(Integer v)

      { return "int "+v; }

      public String getFoo(String v)

      { return "str "+v; }

      }
      2. put an instance of Helper and a collection containing two items of
      different types
      col = new ArrayList();
      col.add(new Integer(100));
      col.add("STRVALUE");
      ctx.put("helper", new Helper());
      ctx.put("col", col);
      3. in a template, do
      #foreach ( $item in $col )
      ${helper.getFoo($item)
      #end
      4. evaluate the template and you should see
      int 100
      ${helper.getFoo($item)

      The error: the second item should invoke getFoo(String) but it apparently
      fails and causing the invocation failure.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              cutebear103@hotmail.com Hacking Bear
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: