You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jason Clawson <jc...@CONTROLPATH.com> on 2008/04/03 00:48:28 UTC

Velocity configuration

I am fairly new to velocity and I have a couple of seemingly simple
questions I could not find the answer for.  If support for the following
2 situations don't exist I would love to see them implemented.

 

1)      Is it possible to configure velocity to do custom method
discovery.  For example we have some legacy code where functions were
not really named in a standard way.  So, in velocity, when you do
$object.variable it will not be able to find the getter function to
access it.

a.       Ideally I would like to provide a factory that would allow me
to use reflection to discover which function to call

b.      This would also allow me to use annotations to restrict the
calling of certain functions

 

2)      Is it possible to change the way velocity handles NULL values
and/or values it doesn't find.  Whenever velocity encounters a value
that is null or undefined it prints out the template markup ie:
$object.variable.  In most cases I would like velocity to simply remove
the markup... especially with a null value.

 

Thanks for your help,

 

Jason Clawson


Re: Velocity configuration

Posted by Claude Brisson <cl...@renegat.net>.
Hi,

Le mercredi 02 avril 2008 à 16:48 -0600, Jason Clawson a écrit :
> I am fairly new to velocity and I have a couple of seemingly simple
> questions I could not find the answer for.  If support for the following
> 2 situations don't exist I would love to see them implemented.
> 
>  
> 

> 1)      Is it possible to configure velocity to do custom method
> discovery.  For example we have some legacy code where functions were
> not really named in a standard way.  So, in velocity, when you do
> $object.variable it will not be able to find the getter function to
> access it.
> 
> a.       Ideally I would like to provide a factory that would allow me
> to use reflection to discover which function to call
> 
> b.      This would also allow me to use annotations to restrict the
> calling of certain functions
> 

You can use a custom "Uberspector" by setting 

runtime.introspector.uberspect = mypackage.MyCustomIntrospector
 
in your velocity.properties file. See
http://velocity.apache.org/engine/releases/velocity-1.5/apidocs/org/apache/velocity/util/introspection/Uberspect.html


> 
> 2)      Is it possible to change the way velocity handles NULL values
> and/or values it doesn't find.  Whenever velocity encounters a value
> that is null or undefined it prints out the template markup ie:
> $object.variable.  In most cases I would like velocity to simply remove
> the markup... especially with a null value.

You can use quiet references: $!object.variable

Or see http://markmail.org/message/in5zobyfyti5m7ln as an exemple of how
to make all references quiet by default.



  Claude

>  
> 
> Thanks for your help,
> 
>  
> 
> Jason Clawson
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org