[ 
https://issues.apache.org/jira/browse/VELOCITY-12?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13013672#comment-13013672
 ] 

Candid Dauth commented on VELOCITY-12:
--------------------------------------

I would really like to see this implemented. In my opinion it is the most 
expected and obvious behaviour that $test.bla can be resolved when the object 
has a public property bla. It seems stupid to me that currently, you cannot 
access that data without using a helper function.

I have created a patch to fix this issue in velocity 1.7. As I don’t seem to be 
able to upload attachments here, it is available on 
http://pastebin.com/QqABn90y. Also, as I rely on this feature myself, I have 
checked in the source code on https://gitorious.org/cdauth/velocity and have 
made it available via Maven on 
http://mvn.cdauth.eu/releases/org/apache/velocity/velocity/.

> Access to public member variable of a class
> -------------------------------------------
>
>                 Key: VELOCITY-12
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-12
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.1
>         Environment: Operating System: All
> Platform: PC
>            Reporter: Rich Doyle
>            Priority: Minor
>
> It would be nice if I could reference public instance variables in a class 
> that 
> is put in the velocity context using a syntax such as 
> $theClass.instanceVarName.  I am aware that this syntax is used to reference 
> the getInstanceVarName() method of the class that is put in the 
> context...maybe 
> a variation on the syntax could be used for instance variables.  I am also 
> aware that it is probably not good to expose instance variables as public, 
> however the classes I am dealing with are generated via a CORBA IDL compiler. 
>  
> My servlet makes a CORBA call, which returns data in such an object (public 
> instance vars, no accessor methods), and it would be nice if I could stuff 
> this 
> object into the velocity context and reference it directly in a template.  
> What 
> I have to do with the current implementation of velocity is wrap these IDL 
> compiler generated classes to provide get methods for the instance variables. 
>  
> This is very easy, but adds up to a lot of classes that exist merely so 
> public 
> members can be accessed via a get method.
> <bootlickingon> I evaluated velocity as an alternative to JSP for use on my 
> current project, and Velocity wins hands down, even given this 
> inconvenience.</bootlickingoff>

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to