Discussion:
[FreeMarker-user] No other way of handling missing values?
tim
2015-02-13 12:16:27 UTC
Permalink
I am checking on a flag that sometimes is missing/NULL and sometimes it
exists in the model but is false.

The only way to securely check on the flag I found is:

<#if (c.royaltyTerms.OffsetLimit.perProductYn)??> (see if it is NULL)
<#if (c.royaltyTerms.OffsetLimit.perProductYn=="Y")> (see if is true/set)

Is there no better way? I appreciate the possibility of differentiating
between NULL and existing, but it is only very rare cases in which such a
check is required. In 90% of the cases you want a missing value be treated
as an existing but not matching value... In the freemarker docs it says that
Freemarker is picky about NULL values in its standard configuration. But I
found no configuration to change this behavior. Is there any?

Cheers,
Tim



--
View this message in context: http://freemarker.624813.n4.nabble.com/No-other-way-of-handling-missing-values-tp4655373.html
Sent from the freemarker-user mailing list archive at Nabble.com.
Andy
2015-02-13 12:35:46 UTC
Permalink
probably this still works:

<#if (((c.royaltyTerms.OffsetLimit.perProductYn)!"N")=="Y")>
Post by tim
I am checking on a flag that sometimes is missing/NULL and sometimes it
exists in the model but is false.
<#if (c.royaltyTerms.OffsetLimit.perProductYn)??> (see if it is NULL)
<#if (c.royaltyTerms.OffsetLimit.perProductYn=="Y")> (see if is true/set)
Is there no better way? I appreciate the possibility of differentiating
between NULL and existing, but it is only very rare cases in which such a
check is required. In 90% of the cases you want a missing value be treated
as an existing but not matching value... In the freemarker docs it says that
Freemarker is picky about NULL values in its standard configuration. But I
found no configuration to change this behavior. Is there any?
Cheers,
Tim
Daniel Dekany
2015-02-13 19:45:58 UTC
Permalink
If only the last step in the chain can be missing (`perProductYn`),
then you don't need all that (...). And as Andy said, you could use
`exp!default == exp`. You can also use `exp! == exp` as `"" != "Y"`.
So at the end you end up with:

<#if c.royaltyTerms.OffsetLimit.perProductYn! == "Y">
Post by tim
I am checking on a flag that sometimes is missing/NULL and sometimes it
exists in the model but is false.
<#if (c.royaltyTerms.OffsetLimit.perProductYn)??> (see if it is NULL)
<#if (c.royaltyTerms.OffsetLimit.perProductYn=="Y")> (see if is true/set)
Is there no better way? I appreciate the possibility of differentiating
between NULL and existing, but it is only very rare cases in which such a
check is required. In 90% of the cases you want a missing value be treated
as an existing but not matching value... In the freemarker docs it says that
Freemarker is picky about NULL values in its standard configuration. But I
found no configuration to change this behavior. Is there any?
Cheers,
Tim
--
http://freemarker.624813.n4.nabble.com/No-other-way-of-handling-missing-values-tp4655373.html
Sent from the freemarker-user mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
FreeMarker-user mailing list
https://lists.sourceforge.net/lists/listinfo/freemarker-user
--
Thanks,
Daniel Dekany
Loading...