velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <>
Subject Re: setting variables with VelocityLayoutServlet
Date Fri, 16 Jul 2004 18:07:32 GMT
"Charles N. Harvey III" <> wrote:
> The $screen_content is processed first, right.  I knew that too because
> I often set variables in the screen that I then access from my "wrapper".
> But this time I need a variable available in lots of screens and I don't
> want to have to set it in all of them.  And, its not one of them static
> variables.  We have a setting in our tomcat servers that tells the app
> which server it is on (development, staging, production).  On each server
> some things change.  So I want my $server to be available to all the
> screens and layouts.
> Looks like it ain't gonna work exactly the way I want it to.  Which is ok.
> The more I look at the code, its really only about 10 screens that need
> the variable so I can call a macro from each of them.
> I'm almost considering overriding the VLS and adding my variable to the
> velocity context.  Maybe later though.  :)

I read such settings from the database (each database has a field that 
identifies whether it's production/development/etc), then dump them into my 
servletContext in the contextInitialized method.


Then it's a simple matter to read it from a vm page using


This works for me both on my layout page as well as on all other vm 
templates processed.

This seems like a better way than subclassing the VLS.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message