Expand my Community achievements bar.

SOLVED

How to iterate Map in sightly?

Avatar

Level 7

Hi Team,

How to iterate a Map in sightly?

Thanks,

AryA.

1 Accepted Solution

Avatar

Correct answer by
Employee

You could do something like this:

<div data-sly-list="${customPage.map.keySet}">
${item}
</div>

View solution in original post

3 Replies

Avatar

Level 7

Feike,

Actually as per my requirements my sightly java class will have a HashMap in which I'm storing some data which I need to display in a page. How can I iterate Map in sightly to get this data? you can just provide me solution for the below HashMap. I will apply the same to my HashMap.

Map map = new HashMap();

map.put(1, "One");

map.put(2, "Two");
map.put(3, "Three");

I checked the tutorials as well I didn't find solution for Map :( .

Thanks,

AryA.

Avatar

Correct answer by
Employee

You could do something like this:

<div data-sly-list="${customPage.map.keySet}">
${item}
</div>