FreeMarker if statement comparing two values
up vote
0
down vote
favorite
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)??
freemarker
add a comment |
up vote
0
down vote
favorite
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)??
freemarker
Why's there nochangedUser(as the error message says)? Is that intended to happen? (Why doesn't the quoted tip help?)
– ddekany
Nov 9 at 23:50
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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)??
freemarker
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)??
freemarker
freemarker
edited Nov 12 at 13:15
user7294900
18.3k93056
18.3k93056
asked Nov 9 at 20:06
Samarland
193114
193114
Why's there nochangedUser(as the error message says)? Is that intended to happen? (Why doesn't the quoted tip help?)
– ddekany
Nov 9 at 23:50
add a comment |
Why's there nochangedUser(as the error message says)? Is that intended to happen? (Why doesn't the quoted tip help?)
– ddekany
Nov 9 at 23:50
Why's there no
changedUser (as the error message says)? Is that intended to happen? (Why doesn't the quoted tip help?)– ddekany
Nov 9 at 23:50
Why's there no
changedUser (as the error message says)? Is that intended to happen? (Why doesn't the quoted tip help?)– ddekany
Nov 9 at 23:50
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Add null check to condition changedUser??:
<#if changedUser?? && user.cellPhone != changedUser.cellPhon>
Still not working
– Samarland
Nov 9 at 21:38
1
Should bechangedUser??instead ofchangedUser != null. FreeMarker 2 has nonull.
– ddekany
Nov 9 at 23:52
1
@Samarland updated according to ddekany comment
– user7294900
Nov 10 at 5:31
Needed it to add ?? for both condition (user.cellPhone?? != changedUser.cellPhon??)
– Samarland
Nov 12 at 13:14
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Add null check to condition changedUser??:
<#if changedUser?? && user.cellPhone != changedUser.cellPhon>
Still not working
– Samarland
Nov 9 at 21:38
1
Should bechangedUser??instead ofchangedUser != null. FreeMarker 2 has nonull.
– ddekany
Nov 9 at 23:52
1
@Samarland updated according to ddekany comment
– user7294900
Nov 10 at 5:31
Needed it to add ?? for both condition (user.cellPhone?? != changedUser.cellPhon??)
– Samarland
Nov 12 at 13:14
add a comment |
up vote
1
down vote
accepted
Add null check to condition changedUser??:
<#if changedUser?? && user.cellPhone != changedUser.cellPhon>
Still not working
– Samarland
Nov 9 at 21:38
1
Should bechangedUser??instead ofchangedUser != null. FreeMarker 2 has nonull.
– ddekany
Nov 9 at 23:52
1
@Samarland updated according to ddekany comment
– user7294900
Nov 10 at 5:31
Needed it to add ?? for both condition (user.cellPhone?? != changedUser.cellPhon??)
– Samarland
Nov 12 at 13:14
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Add null check to condition changedUser??:
<#if changedUser?? && user.cellPhone != changedUser.cellPhon>
Add null check to condition changedUser??:
<#if changedUser?? && user.cellPhone != changedUser.cellPhon>
edited Nov 10 at 5:30
answered Nov 9 at 20:35
user7294900
18.3k93056
18.3k93056
Still not working
– Samarland
Nov 9 at 21:38
1
Should bechangedUser??instead ofchangedUser != null. FreeMarker 2 has nonull.
– ddekany
Nov 9 at 23:52
1
@Samarland updated according to ddekany comment
– user7294900
Nov 10 at 5:31
Needed it to add ?? for both condition (user.cellPhone?? != changedUser.cellPhon??)
– Samarland
Nov 12 at 13:14
add a comment |
Still not working
– Samarland
Nov 9 at 21:38
1
Should bechangedUser??instead ofchangedUser != null. FreeMarker 2 has nonull.
– ddekany
Nov 9 at 23:52
1
@Samarland updated according to ddekany comment
– user7294900
Nov 10 at 5:31
Needed it to add ?? for both condition (user.cellPhone?? != changedUser.cellPhon??)
– Samarland
Nov 12 at 13:14
Still not working
– Samarland
Nov 9 at 21:38
Still not working
– Samarland
Nov 9 at 21:38
1
1
Should be
changedUser?? instead of changedUser != null. FreeMarker 2 has no null.– ddekany
Nov 9 at 23:52
Should be
changedUser?? instead of changedUser != null. FreeMarker 2 has no null.– ddekany
Nov 9 at 23:52
1
1
@Samarland updated according to ddekany comment
– user7294900
Nov 10 at 5:31
@Samarland updated according to ddekany comment
– user7294900
Nov 10 at 5:31
Needed it to add ?? for both condition (user.cellPhone?? != changedUser.cellPhon??)
– Samarland
Nov 12 at 13:14
Needed it to add ?? for both condition (user.cellPhone?? != changedUser.cellPhon??)
– Samarland
Nov 12 at 13:14
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232629%2ffreemarker-if-statement-comparing-two-values%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why's there no
changedUser(as the error message says)? Is that intended to happen? (Why doesn't the quoted tip help?)– ddekany
Nov 9 at 23:50