You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Daniel Pfeifer <Da...@tradedoubler.com> on 2006/05/31 10:05:43 UTC

Calling methods in a velocity template

I've got following piece of code:

 

$myUtils.encode($variableone,$variabletwo)

 

($myUtils is a class called MyUtils which I added to the Context by
context.put("myUtils", new MyUtils()).

 

Encode is supposed to return a string and takes two strings, however,
nothing happens except that "$myUtils.encode($variableone,$variabletwo)"
is printed to the screen.

 

Why oh why?

 

Thanks in advance,

Daniel


Re: Calling methods in a velocity template

Posted by Nathan Bubna <nb...@gmail.com>.
to call a method, it must be a public method in a public class.  also,
make sure your variables have the right type.

$myUtils.class.name
$variableone.class.name
$variabletwo.class.name


On 5/31/06, Daniel Pfeifer <Da...@tradedoubler.com> wrote:
> I've got following piece of code:
>
>
>
> $myUtils.encode($variableone,$variabletwo)
>
>
>
> ($myUtils is a class called MyUtils which I added to the Context by
> context.put("myUtils", new MyUtils()).
>
>
>
> Encode is supposed to return a string and takes two strings, however,
> nothing happens except that "$myUtils.encode($variableone,$variabletwo)"
> is printed to the screen.
>
>
>
> Why oh why?
>
>
>
> Thanks in advance,
>
> Daniel
>
>
>

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