velocity-user mailing list archives

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

I have reported a bug

http://issues.apache.org/bugzilla/show_bug.cgi?id=13637

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.

Thanks.

--- 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));
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.

-------------------------------------------------------


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message