Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Velocity calling a vararg method

Tags:

java

velocity

I am trying to call a varargs method from Velocity. The function is defined in a Class named "Abc" as:

public static void function(String ... values)

I set the context as

params.put("concat",new Abc());

The template contains the call to the method as:

$concat.function('Var1','var2')

If I fix the function to have one argument everything works fine, if I move to the varargs (or a byte[] for that matter), it can't resolve it and I don't get back what I wanted. I set some log settings and go that velocity gets:

Null reference [template 'bufferTemplate', line 1, column 1] :
  $concat.function('Kuku','Muku') cannot be resolved.
like image 816
APB Avatar asked Nov 19 '25 22:11

APB


2 Answers

I am using Velocity 1.6.4 and for me it works the way you've written! Update your Velocity! As far as I have seen they have support for varags from version 1.6 !

like image 124
Atticus Avatar answered Nov 21 '25 12:11

Atticus


Got it. I'm using axis, which seems to be using an older version of Velocity. Once velocity was set first in the classpath, it works. Thanks for the help.

like image 42
APB Avatar answered Nov 21 '25 10:11

APB