Hi! I am using NVelocity 1.1 and I need, from the template file, to
access a public field of an object. But it seems that I can only see
properties, not fields. I have autogenerated classes that have only
fields, like this one:

public class Person {
        public string name;
        ...
}

This is the code I am using:

<code>

VelocityEngine velocityEngine = new VelocityEngine();

ExtendedProperties props = new ExtendedProperties();
props.AddProperty("input.encoding", "UTF-8");
props.AddProperty("output.encoding", "UTF-8");
velocityEngine.Init(props);

Template template = velocityEngine.GetTemplate("template.vm");

VelocityContext velocityContext = new VelocityContext();
velocityContext.Put("person", person);

StringWriter writer = new StringWriter();
template.Merge(velocityContext, writer);

</code>

>From the template file, I try to access the 'name' field from the Person
in this way:

$person.name

but it doesn't work.

Any ideas? May be some NVelocity property?

Thank you!

-- 
Milton Pividori
Blog: http://www.miltonpividori.com.ar
Jabber ID: [email protected]
GnuPG Public Key: gpg --keyserver subkeys.pgp.net --recv-key 0x663C185C


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to