velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <>
Subject Re: Using VelocityTools within Veltags
Date Tue, 15 Apr 2003 20:35:17 GMT
Philippe said:
> We would like to deliver a mixed Velocity/jsp where most of the
> Client-Customizable templates would be in Velocity and enclosed within a >
set of Velocity jsp tags from the Veltag project
> We would also like to use the Velocity Tools.
> This brings up the following questions:
> Is this even a good idea ?

hmm... maybe.

> Are VelocityViewServlet or VelocityLayoutServlet required to use the
> VelocityTools ?

no, but right now, they're the easiest way.

> If not, what would the easiest way to be able to access these tools from
> within a Veltag block ?

hmm.  i'm not familiar with the Veltag code or with writing JSP tags at all.
certainly to just use the generic velocity-tools you shouldn't have any
trouble.  i think that'd look like this:

<%@ taglib uri="/WEB-INF/veltag.tld" prefix="vel" %>
<jsp:useBean id="math" class=""
scope="application" />
    <vel:velocity strictaccess="false">
    $math.div("42", "7")

but i imagine you're wanting the more fun struts and view tools.  :-)

for those (which all implement ViewTool), things are a bit trickier.  most
of them will be expecting to have a ViewContext passed to the init(obj)
method before being used.  for that you will probably be best off if you
modify to use a ServletToolboxManager (which would load
tools from a toolbox.xml) and use a ChainedContext (see
VelocityViewServlet.createContext()) that would then wrap the JSPContext and
give toolbox access.  oh, and if you go that route, then you might as well
drop the "strictaccess" attribute and support from the velocity tag, because
the ChainedContext will expose everything automatically.  if you're still
interested in keep that strictaccess control, then that's another matter.

anyway, i think this is an interesting idea with some potential for further
assisting people in the transition from Struts/JSP to Struts/Velocity (or
even from JSP to Velocity in general).  so, if you end up implementing this,
i hope you'll consider sharing the results (either story of experience or,
even better, code!).   i'll try to help as i am able.

Nathan Bubna

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

View raw message