Question

The following line of code is a generic version of a line in a template I'm working on. I have looked at the Velocity Template Language Documentation but I keep getting 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)
Was it helpful?

Solution

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top