velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Winson Quock <>
Subject Fail to call overloaded methods in foreach loop
Date Mon, 11 Nov 2002 19:48:04 GMT

I have reported a bug

but has not seen any update to it. I would like to see if there is any
workaround than to make all my overloaded method private and to create public
one that takes generic class as arguments.

Or if this will be fixed soon.


--- the bur reported ---

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));
ctx.put("helper", new Helper());
ctx.put("col", col);
3. in a template, do
#foreach ( $item in $col )
4. evaluate the template and you should see
int 100

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


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message