How to fetch the values from multifield child nodes by using HTL? | Community
Skip to main content
July 19, 2022
Solved

How to fetch the values from multifield child nodes by using HTL?

  • July 19, 2022
  • 2 replies
  • 5343 views

i have multifield component and the property (composite=true) so its storing the values one by one like nodes, without using sling model is there any way to get values from those nodes like using htl(sightly).

i tried myself when this component have property (composite=false) so its storing the values in string array format and i used this one...its working but dont know for (composite=true)...


label: ${resource.label}<br>
number:${resource.number}

<div data-sly-resource="${'/content/training/homepage/jcr:content/parsys/multifieldcomponentt' }

 

</div>

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by sravs

Hi @mrmachi ,

 

if you are creating any component with multifield (composite = true) It would be easier to create either a Sling Model or Java / Javascript Use API class to get the list and then use it in the HTL file.

 

But, if you want to access them through HTL you can refer this article where it will differentiate the usage of multifield using sling models/ only through pure HTL.

https://levelup.gitconnected.com/aem-how-to-use-nested-multifields-in-your-components-using-a-sling-model-vs-pure-htl-92ff8d036ba1

 

 

2 replies

sravs
Community Advisor
sravsCommunity AdvisorAccepted solution
Community Advisor
July 19, 2022

Hi @mrmachi ,

 

if you are creating any component with multifield (composite = true) It would be easier to create either a Sling Model or Java / Javascript Use API class to get the list and then use it in the HTL file.

 

But, if you want to access them through HTL you can refer this article where it will differentiate the usage of multifield using sling models/ only through pure HTL.

https://levelup.gitconnected.com/aem-how-to-use-nested-multifields-in-your-components-using-a-sling-model-vs-pure-htl-92ff8d036ba1

 

 

Manu_Mathew_
Community Advisor
Community Advisor
July 19, 2022

@mrmachi Its recommonded to use sling model to get the list and then use it in the HTL file accordingly.

You can use

@ChildResource
private <ClassName> <objName>