Pergunta

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)
Foi útil?

Solução

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)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top