Re: Documentation regarding Custom Utility Class for Velocity
"O. Olson" <[email protected]> Thu, 8 Aug 2013 21:01:17 +0100 (BST)
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <[email protected]> |
Thank you very much Nathan for clarifying this. I somehow missed the documentation where it says that Velocity does not expose fields. I liked your suggestion for FieldMethodizer. This does exactly what I wanted. I think I am set now :-). Thanks again, O. O. ----- Messaggio originale ----- Da: Nathan Bubna <[email protected]> A: Velocity Users List <[email protected]>; O. Olson <[email protected]> Cc: Inviato: Giovedì 8 Agosto 2013 14:06 Oggetto: Re: Documentation regarding Custom Utility Class for Velocity If you are putting the MyUtil class into the context yourself (as your code seems to suggest, then it is up to you whether you want to create a single static instance or a new instance for each request. This is out of Velocity's control as you describe things. If you'd like tool instantiation to be managed for you, you may use the VelocityTools library, either the VelocityView or even just the GenericTools support. I can go into this further if the documentation and examples aren't clear. Bean syntax is optional for methods. You can always call methods with the full name if you like: $myUtil.getNumRows() Velocity does not (by default) expose fields, even public final constant ones. This is documented thoroughly. You can adapt the object to expose fields: http://velocity.apache.org/engine/releases/velocity-1.7/apidocs/org/apache/velocity/app/FieldMethodizer.html or Velocity itself: http://maven-doccheck.sourceforge.net/samples/ShinobuDemo/apidocs/org/apache/velocity/tools/generic/introspection/PublicFieldUberspect.html