mardi 2 octobre 2018

Velocity Template Language: Connect two conditions in one #elseif() statement

In my example the parameters are:

$p2.length

which has the value "0"

and the boolean

$suspectYesNo which is set to "false".

I would expect, that in my code the second #elseif will run due to my set parameters, but however it shows up that "Code 4 runs"

I guess, that my mistake is the connection of both conditions using "&&", but I have no clue how to correctly define the line with two conditions.

That brings me to the question: How to correctly combine the two conditions ($p2.length()==0) AND ($suspectYesNo.value.contains("true")) in one #elseif().

Or did I define the boolean wrong?

  #if($p2.length()>0)

  Code 1 runs

  #elseif($p2.length()==0 && $suspectYesNo.value.contains("true"))

  Code 2 runs

  #elseif($p2.length()==0 && $suspectYesNo.value.contains("false"))

  Code 3 runs

  #else

  Code 4 runs

  #end

Aucun commentaire:

Enregistrer un commentaire