velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <>
Subject Re: best practice question
Date Wed, 02 Mar 2005 16:12:30 GMT
that's very strange.  what you're doing looks fine to me and
definitely should work.  and no, it shouldn't make a difference
whether the methods are static or not.  they just need to be public
methods in public classes.  so, the first thing i suggest
double-checking is that the Constants class is declared public.  if
it's not, it would explain why toString() works, but your methods
don't (toString() is in Object, which is declared public).

if that's not the problem, then would you send your Constants class
itself for us to try this out?  if you're not comfortable or allowed
to show it to the public list, you could just send it to me, and i'll
try it out.

On Wed, 02 Mar 2005 08:58:35 -0500, Matthew Van Horn
<> wrote:
> I use a Constants class in my application to hold a bunch of strings
> used for things like request attribute keys etc. In my templates, I
> would also like to eliminate the hard-coded strings, and I thought I
> could do that by using the Constants class as a tool.
> <tool>
>         <key>const</key>
>         <scope>application</scope>
>         <class></class>
> </tool>
> public class Constants {
>         public static final String PROPERTY = "";
>         //etc..
>         //I even tried this:
>         public static String getPROPERTY() {
>                 return PROPERTY;
>         }
> }
> in my template
> $const.PROPERTY
> $const.getPROPERTY()
> both turn up as invalid references.
> but $const.toString() works, so an object must be there.
> Is this something to do with static methods? I added a non-static method
> to test, but that didn't work either.
> Do I need to implement the ViewTool interface? What should I do in
> init() then?
> According to the docs available I thought this was possible, but now I
> am stumped. Hope I won't feel too stupid upon figuring this out.
> Thanks for any help,
> Matt Van Horn
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message