0

In my ftl file, I'm writing:

<#list myDataList as myData>
<p>
    <#if myData.action == 0>Added by
    <#else>Removed from
    </#if>
</p>
</#list>

In java code, action is of type Integer.

I've also tried myData.action == "0".

I can see action == 0 while debugging.

Error I'm getting:

freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> myData.action  [in template "email_template.ftl" at line 79, column 50]
sonic boom
  • 764
  • 4
  • 11
  • 26
  • 1
    Try with default value as `myData.action!"0" == "0"` or `(myData.action)!"0" == "0"` – Ori Marko Jul 06 '21 at 09:20
  • Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Kitswas Jul 06 '21 at 09:22
  • 1
    @user7294900 Default values need not be a strings. So it should be this to avoid any number formatting issues (like the `action` is present, and then auto converted to `0.0`): `myData.action!0 == 0` – ddekany Jul 09 '21 at 12:36

1 Answers1

0

null is different from 0 (zero). Try a "Missing value test" instead:

myData.action?? == false
Ole Pannier
  • 3,208
  • 9
  • 22
  • 33