velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: conditional operator - Macro Format Mystery Solved
Date Fri, 11 May 2001 11:49:23 GMT
David Duddleston wrote:
> 
> Ahhh... in my first attempt to use a macro, I did not realize the macro was
> sort of cached. Figured out that I need to reload the Servlet to use a new
> macro with the same name. Anyway when I changed this macro
> 
> #macro( bgc $count )
> #if( $count%2==0 )
> #66CCFF#else
> #EEEEEE#end
> #end
> 
> to this
> 
> #macro( bgc $count )
> #if( $count%2==0 )#66CCFF#else#EEEEEE#end
> #end
> 
> and reloaded the Servlet... it took the new format. Now I'll have to see if
> there is a property regarding macro being cached.
> 

Yes, the default setting is that a global macro is protected from being
overwritten.

TO change this, set the property

velocimacro.permissions.allow.inline.to.replace.global  to true

OR

velocimacro.permissions.allow.inline.local.scope  ->  true

should prevent your macros from becoming 'global' in the first place.

To set these, and you are using the default mechanism in
VelocityServlet, just add them to your properties file, or do it
directly, a la

Velocity.setProperty("velocimacro.permissions.allow.inline.to.replace.global",
Boolean.TRUE );

in the right place.  Where 'the right place' is depends on your
initialization strategy.  Lately, out of sheer lazyness, I have been
overriding loadConfiguration(), and doing the entire setup of the
runtime engine in there, calling Velocity.init() to make sure it's
done.  The servlet init() will subsequently try to set properties and
call init, but since I have already init()-ed, it's done.

I guess we should add a little initVelocity() method call that you can
override.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."

Mime
View raw message