Menu

multiple if or else if

2020-02-12
2020-02-12
  • Victor Florescu

    Victor Florescu - 2020-02-12

    Hello,

    Is it possible to implement multiple condition check ?
    for example :
    if (a && b) -> x
    if (!a && b) -> y
    if (!a && !b) -> z

     
  • Victor Florescu

    Victor Florescu - 2020-02-12

    Hello,

    I found a solution. Maybe it will help someone :
    Basic java code inside the else attribute

    <jt:if test="${condition1}" then="${expression1}" else="${if(condition2)){expression2} else {expression3} }"></jt:if>

    So we could do like:
    condition1 = !b ; expression1 = z
    condition2 = a ; expression2 = x
    expression 3 = y (in case !!b, !a)

    Edit : my if tag is a bodiless one. It ends with " /> but here it shows with an end tag, I dont know how to change it.

     

    Last edit: Victor Florescu 2020-02-12

Log in to post a comment.