2

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)
starwarswii
  • 2,187
  • 1
  • 16
  • 19
Bobby
  • 18,217
  • 15
  • 74
  • 89

1 Answers1

2

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
  • 109,619
  • 77
  • 317
  • 330