Thank you Mauricio! El mar, 20-10-2009 a las 15:47 -0700, Mauricio Scheffer escribió: > Take a look at the FieldMethodizer (especially its comments): > > http://svn.castleproject.org:8080/svn/castle/NVelocity/trunk/src/NVelocity/App/FieldMethodizer.cs > > On Oct 20, 7:28 pm, Milton Pividori <[email protected]> wrote: > > 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 > > -- 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 -~----------~----~----~----~------~----~------~--~---
