Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
How to get the document uuid in a adt
Hi,
I'm trying to show a documents and media PDF in a Asset
Publisher Template using documents and media structure field and
the
URL that i get is this one :
https://innoval.zylk.net/en/web/guest/{
What I'm doing is this:
<#assign dlFile =
saxReaderUtil.createXPath("dynamic-element[@name='documents']").selectSingleNode(rootElement).getStringValue()
>
<p><a href="${dlFile}"
target="_blank" >Download</a></p>
When i print on screen the var dlFile, it shows :
{"groupId":"20127","title":"8a66f5c8-ea38-b0f1-34dd-73447f62b882","type":"document","uuid":"8b418808-4ec6-5100-8169-368fc080611f"}
How can i get the uuid value?
I have tried to use the ?split, a list like this:
<span><#</span><span>list dlFile as</span><span> value</span><span>></span><span>
</span><span> $</span><span>{</span><span>value</span><span>}</span><span>
</span><span></#</span><span>list</span><span>></span><span> </span>
But they doesn't work
Could someone help me??
I hope u can help me..
Lots of thanks.
Hello,
{"groupId":"20127","title":"8a66f5c8-ea38-b0f1-34dd-73447f62b882","type":"document","uuid":"8b418808-4ec6-5100-8169-368fc080611f"}
If your JSON is like above than you can use below code for fetching uuid.
<#list dlFile as value>
${value.uuid}
</#list>
Thanks
Vishal Munjani
Hello Vishal Munjani,
Thanks for your answer but it doesn't work, i still have a problem it says me this:
For "#list" list source: Expected a sequence or collection, but this has evaluated to a string (wrapper: f.t.SimpleScalar):
I hope u could help me.
Josu U.
Hello
I have tried below code and it is worked for me.Please check with below code.
<#assign dlFile= {"groupId":"20127","title":"8a66f5c8-ea38-b0f1-34dd-73447f62b882","type":"document","uuid":"8b418808-4ec6-5100-8169-368fc080611f"}>
${dlFile.uuid}
Thanks
Hello,
Thanks for your answer, i have cheeked your code and it works.
The problem is that im in the develop enviroment and when i migrate to the production enviroment it will fail.
Is there any other solution without hard-codeing?
Thanks,
Josu U.
josu urrutia:For "#list" list source: Expected a sequence or collection, but this has evaluated to a string (wrapper: f.t.SimpleScalar):
Based on this error message, it sounds like dlFile is a
string, so you can't treat it like a list. Given that, have you tried
following the blog post on Working
with JSON in Freemarker to convert your dlFile
variable from a string into a JSON object?
<#assign dlFile_hashmap = jsonFactoryUtil.looseDeserializeSafe(dlFile) >
${dlFile_hashmap.uuid}
Hello Minhchau Dang,
Thank you for your answer, the link you give me help me a lot.
Regards,
Josu U.