Sightly:How to iterate Map<String, Map<String, Map<ModelObject, List<ModelObject>>>> | Community
Skip to main content
Level 2
Aug 22, 2017 10:38 AM UTC

Sightly:How to iterate Map<String, Map<String, Map<ModelObject, List<ModelObject>>>>

Hi All,

I am not able to iterate the below map in sightly.

Map<String, Map<String, Map<ModelObject, List<ModelObject>>>>

I want to parse this map and read all the elements in all objects.

Please help.

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

7 replies

kautuk_sahni
Employee
Aug 22, 2017 11:08 AM UTC

Did you chek this post: Sightly : How to Iterate through Map&lt;String , Map&gt;

//Here an example the shows how it can be done, without java code.

  https://github.com/heervisscher/htl-examples/blob/master/core/src/main/java/com/adobe/examples/htl/core/hashmap/HashMapExample.java

HTL-code:

<div data-sly-use.hashmap="com.adobe.examples.htl.core.hashmap.HashMapExample"

     data-sly-list="${hashmap.map.keySet.iterator}">

     ${item}

     <ul data-sly-list.aem="${hashmap.map[item].keySet.iterator}">

         <li>${aem} ${hashmap.map[item][aem]}</li>

     </ul>

</div>

Another post List of maps in Sightly

Helpx https://helpx.adobe.com/experience-manager/using/htl_movie62.html

~kaututk

Translate
Kautuk Sahni
Level 2
Aug 22, 2017 11:24 AM UTC

Yes I checked this post and I am able to iterate but I am not able to iterate this below mentioned part of map.

Map<ModelObject, List<ModelObject>>

I am able to get key of above map, but I am not able to get value which is list of model object.

Translate
smacdonald2008
Level 10
Aug 22, 2017 2:00 PM UTC

Kautuk pointed you to valid code to iterate collections. Also see this article for another example:

Adobe Experience Manager Help | Creating an Adobe Experience Manager HTL component that displays a repeating data set

This HTL component works with a Collection as well. For your example, make sure that you correctly reference the element in the collection using correct HTL syntax.

Translate