You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Peter Anning <pe...@bigfoot.com> on 2004/02/18 08:39:58 UTC
Fw: Accessing properties values from VTL
Hi,
I have a value in the properties file (velocity.properties)
tools.view.servlet.layout.directory = decorators/
is there a way to reference this value from a VTL (.vm) file
e.g. how to make this reference
#set($layout_dir = <tools.view.servlet.layout.directory> )
Thanks and Regards
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Accessing properties values from VTL
Posted by Nathan Bubna <na...@esha.com>.
Peter Anning said:
> I have a value in the properties file (velocity.properties)
>
> tools.view.servlet.layout.directory = decorators/
>
> is there a way to reference this value from a VTL (.vm) file
>
> e.g. how to make this reference
>
> #set($layout_dir = <tools.view.servlet.layout.directory> )
at the present, this value is not automatically placed in the context for you.
i think the simplest way for you to get it would be to extend the
VelocityLayoutServlet and add it to the servlet context attributes during the
servlet's init: e.g.
public class MyServlet extends VelocityLayoutServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
String layoutdir = Velocity.getString(PROPERTY_LAYOUT_DIR,
DEFAULT_LAYOUT_DIR);
config.getServletContext().setAttribute("layout_dir", layoutdir);
}
}
if you feel that adding access to certain/all property values from VTL is a
useful thing in general, i would suggest adding an enhancement request to
Bugzilla along with a simple explanation of what this would be used for. such
a change won't make it into the 1.1 release, but might be worth considering
for 1.2.
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