velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Wilson" <>
Subject RE: Usage question.
Date Tue, 18 Jan 2005 23:29:07 GMT
Thanks, that's great!

OK, so the problem is that it doesn't work with static members eg.

public static final String ID = "ID"

When I change this to 

public String getID() { return "ID" }

It does work.

Is there any way the static version could be made to work?  

Many thanks,

-----Original Message-----
From: [] 
Sent: Wednesday, 19 January 2005 12:54 AM
Subject: Re: Usage question.

Hi Andrew,

> ie the definition is (with package etc)
> public static final String = "ID";
> Then I use this to put things in a HashMap.
> I can get this to work using
> ${request.getProperty("ID")};
> But I wanted the compile time safety of :
> ${request.getProperty(Request.ID")};

Don't know much about WebMacro, but I can think of a couple ways.

1. Put Request.ID in the context.
Let's say, $id.  Then you can do:

2. Put Request in the context, and make a getter method.
Let's say $req and #getId().  Then you can do:

3. Haven't tried it with static fields, but the PublicFieldUberspect.
## You'll still need an instance of Request in the Context.

4. Haven't tried it, but I found a tool here:

Hope that helps.  :)

Best regards,
-- Shinobu

Shinobu "Kawai" Yoshida <>

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


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

View raw message