calling a java method in velocity template

Viewed 30698

I have a class CurrencyUtil in which I have written a method convertCurrency(String symbol, long value) I want to call this method from velocity template. I am putting object of this class map.put("formatter", currencyUtil); and in template I am using the tag as $formatter.convertCurrency($currency, $total) but when the template is rendered it is not printing the result.

here my question is that, should the parameter names in the java method and in template be same? or is there any other problem?

2 Answers

Velocity receives all parameters as Strings. In your function you receive a String and apply a cast.

Related