views:

30

answers:

1

The following line of code is a generic version of a line in a template I'm working on. I have locked at the Velocity Template Language Documentation but I keep gettting errors no matter how I format this statement. This is my first real experience with VTL so I was hoping to get a set of experienced eyes on the issue:

#set($includeAttributes = 
   ${firstResponseItem.attribute1} != null || 
   ${firstResponseItem.attribute2 != null)
+1  A: 

There is no null in Velocity, but you can check for a null value as if it was boolean false:

#set($includeAttributes = $firstResponseItem.attribute1 || $firstResponseItem.attribute2)
serg