Last active
July 9, 2021 18:18
-
-
Save evertonthepaula/f361f5c535783ded257470a9ac5d800e to your computer and use it in GitHub Desktop.
Liferay - ADT - get dynamic fields value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#if entries?has_content> | |
<#list entries as curEntry> | |
<#assign AssetRenderer = curEntry.getAssetRenderer()> | |
<#assign journalArticle = AssetRenderer.getArticle() /> | |
<#assign document = saxReaderUtil.read(journalArticle.getContent()) /> | |
<#assign rootElement = document.getRootElement() /> | |
<!-- FORMA 01 --> | |
<#list rootElement.elements() as dynamicElement> | |
<#assign elementData = dynamicElement.element("dynamic-content").getData()/> | |
<#assign elementText = dynamicElement.element("dynamic-content").getText()/> | |
<mark>${dynamicElement.getName()}</mark><br> | |
${elementData}<br> | |
${elementText}<br></hr> | |
</#list> | |
<!-- FORMA 02 --> | |
<#assign xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='NOME_DO_CAMPO_QUE_VOCE_DESEJA']")/> | |
<#assign NOME_DO_CAMPO_QUE_VOCE_DESEJA = xPathSelector.selectSingleNode(rootElement).getStringValue()/><br></hr> | |
${NOME_DO_CAMPO_QUE_VOCE_DESEJA} | |
<!-- FORMA 03 --> | |
<#function getFieldValue name> | |
<#assign xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='${name}']")/> | |
<#assign value = xPathSelector.selectSingleNode(rootElement).getStringValue()/> | |
<#return value> | |
</#function> | |
<b>Terceira Forma: </b> ${getFieldValue(NOME_DO_CAMPO_QUE_VOCE_DESEJA)} <br /><hr> | |
<!-- FORMA 04 - USANDO CUSTOM FIELDS --> | |
<#assign AssetRenderer = curEntry.getAssetRenderer()> | |
<#assign Fields = AssetRenderer.getDDMFormValuesReader().getDDMFormValues().getDDMFormFieldValues()/> | |
<#list Fields as field> | |
<b>${field.getName()}</b>: ${field.getValue()}<br> | |
<b>${field.getName()}</b>: ${field.getValue().getString(locale)}<hr> | |
</#list> | |
</#list> | |
</#if> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment