velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nat...@esha.com>
Subject Re: setting variables with VelocityLayoutServlet
Date Fri, 16 Jul 2004 16:48:41 GMT
Charles N. Harvey III said:
> I was wondering about setting global variables in my templates when
> I am using the VVS.  If I do a #set( $myVar = "thing" ) in my layout.vm
> page, that variable does not show up in the page that is called up in
> the $screen_content.  Is there a way to do this?  Is there a #global
> directive?

layout.vm?  $screen_content?  it sounds like you're using the VLS, not the
VVS.  :)

the thing to remember about the VelocityLayoutServlet is that the screen
template ($screen_content) is processed first.  so anything that it sets in
the context is available to the layout template, but not vice versa.  anything
that happens in the layout template happens after the screen processing is
already over.  so the simple answer is "no."

however, it is possible (and quite easy) to make variables available to both
layout and screen before either of them is processed, because anything made
available to the screen is available to the layout as well.

and there's always the application-wide way to specify global variables in the
toolbox:

<data type="string">
    <key>myVar</key>
    <value>thing</key>
</data>

Nathan Bubna
nathan@esha.com


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


Mime
View raw message