Foros de discusión

How to get nested field in ADT

thumbnail
Arthur Marinho, modificado hace 7 años.

How to get nested field in ADT

New Member Mensajes: 24 Fecha de incorporación: 13/01/15 Mensajes recientes
Hi everyone

I'm trying to retrieve a nested field that is inside a repeatable field. All of this within an ADT using Freemarker Template Engine.
What isn't working is the nested 'check' field inside the 'title'. Somehow it's catching always the value from the first checkbox and repeating through the entire loop.


How can I get the value from a field that is inside a repeatable field?



<#if entries?has_content>
<#list entries as curEntry>
<#assign assetRenderer = curEntry.getAssetRenderer() >
<#if assetRenderer.getClassName() == "com.liferay.journal.model.JournalArticle">
<#assign journalArticle = assetRenderer.getArticle()>
<#assign docXml = saxReaderUtil.read(journalArticle.getContent())/>
<#assign titleRepeatable = docXml.getRootElement().selectNodes("//dynamic-element[@name='title']")>

<#list titleRepeatable as curTitle>
<#assign check = curTitle.valueOf("//dynamic-element[@name='check']/dynamic-content/text()")>
<!--#list-->

<!--#if-->
<!--#list-->
<!--#if-->



{
   "availableLanguageIds": [
       "de_DE"
   ],
   "defaultLanguageId": "de_DE",
   "fields": [
       {
           "label": {
               "de_DE": "title"
           },
           "predefinedValue": {
               "de_DE": ""
           },
           "style": {
               "de_DE": ""
           },
           "tip": {
               "de_DE": ""
           },
           "dataType": "string",
           "indexType": "keyword",
           "localizable": true,
           "name": "title",
           "readOnly": false,
           "repeatable": true,
           "required": false,
           "showLabel": true,
           "type": "text",
           "nestedFields": [
               {
                   "label": {
                       "de_DE": "check"
                   },
                   "predefinedValue": {
                       "de_DE": false
                   },
                   "style": {
                       "de_DE": ""
                   },
                   "tip": {
                       "de_DE": ""
                   },
                   "dataType": "boolean",
                   "indexType": "keyword",
                   "localizable": true,
                   "name": "check",
                   "readOnly": false,
                   "repeatable": false,
                   "required": false,
                   "showLabel": true,
                   "type": "checkbox"
               }
           ]
       }
   ]
}