velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Glass-Husain" <wgl...@forio.com>
Subject Re: Referencing Object / Class Variables
Date Tue, 20 Dec 2005 00:40:58 GMT
No, just properties and methods.

In the Wiki there's a substitute Uberspector (the plugin that does the 
introspection of properties) that reads fields instead of properties.

Best,

WILL

----- Original Message ----- 
From: "Wm Muir" <muirwa@hotmail.com>
To: <velocity-user@jakarta.apache.org>
Sent: Monday, December 19, 2005 4:09 PM
Subject: Referencing Object / Class Variables


> Greetings,
>
> I am a WebMacro user, trying out Velocity.  Can you reference Object / 
> Class
> variables from within the template like WebMacro?  I have read over the
> documentation, and have tried it myself, but no luck.
>
> For Example:
>
> // Object or Class
> public class Foo {
>   public static final String CAT = "Cat";
>   public String dog = "Dog";
>   ...
> }
>
> // Code
>   Foo foo = new Foo();
>   context.put( "fooObject", foo );
>   context.put( "FooClass", Foo.class );
>
>
> // Template
> $fooObject
> $FooClass
> $fooObject.CAT
> $fooObject.dog
> $fooClass.CAT
>
> This results in:
> com.test.Foo@f346dc   // expect this
> class com.test.Foo    // expect this
> $fooObject.CAT // I would expect 'Cat'
> $fooObject.dog // I would expect 'Dog'
> $fooClass.CAT // I would expect 'Cat'
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
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