So, I'am trying to make simple condition:
<#if documentData.isOtherInsurance>
<p>✔ Да</p>
<#else> <p>✘Нет </p></#if>
and I'm getting mistake like:
For "#if" condition: Expected a boolean, but this has evaluated to a method sequence (wrapper: f.e.b.SimpleMethodModel):
==> documentData.isOtherInsurance!false [in template "InsuranceNotification" at line 1, column 1445]
----
Tip: Maybe using obj.something instead of obj.isSomething will yield the desired value.
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #if documentData.isOtherInsurance!false [in template "InsuranceNotification" at line 1, column 1440]
----
So I tried almost everything
1)
<#if ${documentData.isOtherInsurance>} <p>✔ Да</p> ...
Syntax error in template "InsuranceNotification" in line 1, column 1445:
You can't use ${...} (an interpolation) here as you are already in FreeMarker-expression-mode. Thus, instead of ${myExpression}, just write myExpression. (${...} is only used where otherwise static text is expected, i.e., outside FreeMarker tags and interpolations, or inside string literals.)
CodePudding user response:
Try this:
<#if documentData.isOtherInsurance>
<@displayRow label="isOtherInsurance" value="✔ Да" />
<#else>
<@displayRow label="isOtherInsurance" value="✘Нет" />
</#if>
CodePudding user response:
isOtherInsurance
is a method, as the error messages says, not a boolean
. Try documentData.otherInsurance
(no "is"), which is the Java Bean property that the boolean isOtherInsurance()
Java method automatically defines.
Note that sometimes developers incorrectly declare such methods as Boolean isOtherInsurance()
(with capital Boolean
). Then they should change that to Boolean getOtherInsurance()
, or to boolean isOtherInsurance()
. But if they won't, you can still use documentData.isOtherInsurance()
(note that ()
which will call the method, so then then the return value of the method will be used, instead of the method itself).