velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Revusky <>
Subject Treatment of null variables in Velocity
Date Sat, 14 Jul 2001 23:33:50 GMT
I have been playing with Velocity recently. I actually have a first pass
of integrating velocity as an option in the Niggle web application
framework (it currently supports freemarker and webmacro, but
announcement on velocity forthcoming...). Anyway, I am rather dismayed
about how velocity treats null variables. I frequently use a pattern
where, in a form, I go:

<INPUT TYPE="TEXT" NAME="last_name" VALUE="$record.last_name" SIZE="25">

Or something like that. Where the $record is a wrapper variable around a
database record in my framework. Anyway, if last_name is null, then it
actually puts in the literal string "$record.last_name". I mean, that's
terrible! I could see where that is good at a debugging level, but
really.... I mean, otherwise, you need to make sure that you always
replace this by the empty string. Quite literally, it seems like you
need something like:

#set ($last_name="")
#if ($record.last_name) #set ($last_name = $record.last_name) #end
<INPUT TYPE="TEXT" NAME="last_name" VALUE="$last_name" SIZE="25">

This is awkward! Has there been any discussion of this?


Jonathan Revusky
available for Java/Delphi/Internet consulting
If you want to...
- make your .class files double-clickable with SmartJ
- do Delphi/Java mixed programming with easy-to-use JNI wrapper classes
- build robust web applications with the Niggle Application Framework
check out the Revusky Hacks Page:

View raw message