Samarland
Samarland

Reputation: 581

FreeMarker if statement comparing two values

I'm trying to compare two values

<#if user.cellPhone != changedUser.cellPhon>
    <br><span class="changes">*${changedUser.cellPhone}</span></#if>

I'm getting an error

freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:==> changeUser

Tip:

If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??

Upvotes: 0

Views: 638

Answers (1)

Ori Marko
Ori Marko

Reputation: 58892

Add null check to condition changedUser??:

  <#if changedUser?? && user.cellPhone != changedUser.cellPhon>

Upvotes: 1

Related Questions