Where I use Velocity tools is not rendering html pages. I solely use it as "sql rendering" utility. I have template files where I have sql queries. I use velocity to create the final sql formula string and run it against the database.
And applications are nothing to do with Tomcat, JSP, servlet engines. Its plain old standalone desktop application. I have subclasses VelocityContext and added helper methods. [ templateFile userUpdate.vm ] Update tTable Set id=$userId, updated=$updated, name=$name Where id=$userId ctx = new SQLQueryContext("sql/userUpdate.vm"); ctx.setInt("userId", userBean.getId()); ctx.setDate("updated", userBean.lastUpdated()); ctx.setName("name", userBean.getName()); ... String sql = ctx.createQuery(); Helper class handles all sql escaping (convert single ' to double ''), gives me named parameters, etc... If I want to do something fancy, I can easily create conditional sql template files. #if ($id > 100) Update tTable Set id=$userId, updated=$updated, name=$name Where id=$userId #else Update tTableForLessThan100Ids Set id=$userId, updated=$updated, name=$name Where id=$userId #end --- Nathan Bubna <[EMAIL PROTECTED]> wrote: > While this essay is a bit old, i believe a lot of it > is still relevant. > http://wiki.apache.org/jakarta-velocity/YouMakeTheDecision > > and while JSP 2.0 (with JSTL) is certainly "much > improved", the simple > reality is that its syntax will always be uglier and > more unweildy and > remains restricted to web environments. i've lately > had to work on my > first big JSP/JSTL project and am continually > appalled and some of the > syntactical nonsense i have to deal with. the IDE > support helps > though, as do the Velocity-ish features added with > 2.0 and JSTL. i'm > quite glad to never have been forced to use JSP 1.x > for anything > significant before these came out. > > oh, and your "why take things out of a 'session'..." > complaint is a > shortcoming of whatever servlet/controller you are > using, in my > opinion. if you use the VelocityViewServlet from > the VelocityTools > project, you can automaticaly access session > attributes (and more) > directly in your templates without any need to > manually add them to > your context. > > On 1/11/06, Paul Gillen <[EMAIL PROTECTED]> > wrote: > > My new employer uses Velocity for page display > technology. In answer > > to the question "why?" I get "its our standard". > True, but > > intellectually unsatisfying. Everything else is > written in Java/JSP > > which is in itself a powerful and functionally > rich page display > > technology. Velocity on the other hand appears to > be functionally > > deficient, i.e. the absence of a "for" loop. Even > were this not true, > > why change technologies when we get down to the > view layer? Why take > > things out of a "session" construct only to put > them in a "context" > > construct for the convenience of Velocity when > were we sticking with > > JSP this step would be unnecessary? Not trying to > piss on anybody's > > foot. Looks like lots of folks use it. Looks like > I'm stuck with it. > > But I'm still looking for an answer to the > question, "Why?" __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]