Sightly:How to iterate Map<String, Map<String, Map<ModelObject, List<ModelObject>>>> | Community
Skip to main content
August 22, 2017

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

  • August 22, 2017
  • 1 reply
  • 3940 views

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.

1 reply

kautuk_sahni
Community Manager
Community Manager
August 22, 2017

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

Kautuk Sahni
August 22, 2017

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.

smacdonald2008
August 22, 2017

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.