Re: Handling of optional data tree

Darryl Booms <[email protected]> Wed, 11 Feb 2015 14:08:35 -0500
Newsgroups gmane.comp.web.freemarker.user
Message-ID <CAPW8oVFmv7jvJZG7JzLS3_bkh4Vi5i1EP-UZFahb4uL6DEMf6w@mail.gmail.com>
--===============6095307694625370971==
Content-Type: multipart/alternative; boundary=001a11c3fc3cf5b42c050ed4ba09

--001a11c3fc3cf5b42c050ed4ba09
Content-Type: text/plain; charset=UTF-8

Tim,

Perhaps you can check for the model data's existance first?
<#if (p.share??)> ... </#if>

Darryl
On Feb 11, 2015 10:56 AM, "tim" <[email protected]> wrote:

> Hi,
>
> I have a data model of this kind:
>
> contract
> +contractParties
> +contractParty
> ++share
> +++amount
> +++currency
> ...
>
> I want to display amount and share for each contract party:
> <#list contract[0].contractParties.contractParty as p>
>   Amount: ${p.share.amount!}
>   Share: ${p.share.currency!}
> </#list>
>
> list creates a sequence and that's fine. If there is no contract party,
> this
> will just be omitted -> fine.
> But then I want to access amount anf currency of the share. This works if
> there is a share. It does not work if there is no share, though. If share
> is
> null/empty/missing, it creates an error no matter what I do. I tried
> ${p.share[0].currency!} and ${p.share[0]!.currency!}, but it does not work
> if share is undefined.
>
> Is it possible to either
> - turn off error handling for missing data model fractions or
> - ignore missing paths
> ?
>
> Thanks for your feedback!
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/Handling-of-optional-data-tree-tp4655366.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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--001a11c3fc3cf5b42c050ed4ba09
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">Tim,</p>
<p dir=3D"ltr">Perhaps you can check for the model data&#39;s existance fir=
st?<br>
&lt;#if (p.share??)&gt; ... &lt;/#if&gt;</p>
<p dir=3D"ltr">Darryl</p>
<div class=3D"gmail_quote">On Feb 11, 2015 10:56 AM, &quot;tim&quot; &lt;<a=
 href=3D"mailto:[email protected]">[email protected]</a>&gt; wr=
ote:<br type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have a data model of this kind:<br>
<br>
contract<br>
+contractParties<br>
+contractParty<br>
++share<br>
+++amount<br>
+++currency<br>
...<br>
<br>
I want to display amount and share for each contract party:<br>
&lt;#list contract[0].contractParties.contractParty as p&gt;<br>
=C2=A0 Amount: ${p.share.amount!}<br>
=C2=A0 Share: ${p.share.currency!}<br>
&lt;/#list&gt;<br>
<br>
list creates a sequence and that&#39;s fine. If there is no contract party,=
 this<br>
will just be omitted -&gt; fine.<br>
But then I want to access amount anf currency of the share. This works if<b=
r>
there is a share. It does not work if there is no share, though. If share i=
s<br>
null/empty/missing, it creates an error no matter what I do. I tried<br>
${p.share[0].currency!} and ${p.share[0]!.currency!}, but it does not work<=
br>
if share is undefined.<br>
<br>
Is it possible to either<br>
- turn off error handling for missing data model fractions or<br>
- ignore missing paths<br>
?<br>
<br>
Thanks for your feedback!<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href=3D"http://freemarker.624813.n4.nabble=
.com/Handling-of-optional-data-tree-tp4655366.html" target=3D"_blank">http:=
//freemarker.624813.n4.nabble.com/Handling-of-optional-data-tree-tp4655366.=
html</a><br>
Sent from the freemarker-user mailing list archive at Nabble.com.<br>
<br>
---------------------------------------------------------------------------=
---<br>
Dive into the World of Parallel Programming. The Go Parallel Website,<br>
sponsored by Intel and developed in partnership with Slashdot Media, is you=
r<br>
hub for all things parallel software development, from weekly thought<br>
leadership blogs to news, videos, case studies, tutorials and more. Take a<=
br>
look and join the conversation now. <a href=3D"http://goparallel.sourceforg=
e.net/" target=3D"_blank">http://goparallel.sourceforge.net/</a><br>
_______________________________________________<br>
FreeMarker-user mailing list<br>
<a href=3D"mailto:[email protected]">FreeMarker-user@li=
sts.sourceforge.net</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/freemarker-user" ta=
rget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/freemarker-use=
r</a><br>
</blockquote></div>

--001a11c3fc3cf5b42c050ed4ba09--


--===============6095307694625370971==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
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/
--===============6095307694625370971==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user

--===============6095307694625370971==--