This is a question for the user list.
Le lundi 18 décembre 2006 à 16:04 -0700, John a écrit :
> Hi all,
>
> I'm getting familiarized with Velocity, and I'm wondering about how I should
> handle the following case:
>
> I have a utility class called "Utils". Now typically if I wanted to use the
> member functions in this class in my other Java classes I would declare them
> static and reference them as so "Utils.checkInput(int)".
>
> Now with Velocity and the idea that if I want these utilities available to
> the VTL, I understand I need to put the object in the VelocityContext. From
> what I have seen (for example with the VelocityFormatter tool), a new object
> is created and put in the context
>
> velocityContext.put("formatter", new VelocityFormatter());
>
> So my question is: what do I do with my Utils class? Should I create a new
> instance as well? Does that mean I should change my static methods to
> non-static methods? I guess my inexperience is showing here :)
Why can't you create a new instance of Utils? Static methods can be
called as if they were instance methods.
Claude
> Thanks!
> John
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]