velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shinobu Kawai Yoshida <shinobu.ka...@gmail.com>
Subject Re: Usage question.
Date Tue, 18 Jan 2005 13:54:14 GMT
Hi Andrew,

> ie the definition is (with package etc)
> 
> public static final String com.foo.Request.ID = "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:
   ${request.getProperty($id)}

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

3. Haven't tried it with static fields, but the PublicFieldUberspect.
   http://wiki.apache.org/jakarta-velocity/PublicFieldUberspect
## You'll still need an instance of Request in the Context.

4. Haven't tried it, but I found a tool here:
   http://jakarta.apache.org/velocity/api/org/apache/velocity/app/FieldMethodizer.html

Hope that helps.  :)

Best regards,
-- Shinobu

--
Shinobu "Kawai" Yoshida <shinobu.kawai@gmail.com>

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


Mime
View raw message