I am trying to iterate a multivaluedmap
MultiValuedMap<String, Map<String,List<ModelObj>>> through HTL as below. But, I get values upto two levels which are String. Not able to access ModeObj.
<div data-sly-use.nav="fragmentexamples.core.models.Nav">
<ul data-sly-list.year="${nav.map}">
<div> ${year} </div> ------ First level String gets printed
<ul data-sly-list.type="${year}">
<li>${type} </li> --------Second level String gets printed
${nav.map[year][type]} or ${nav.map[year][type]['modelObjProp']}------- not working
</ul>
</ul>
</div>
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Nithyasri_K ,
Try with below code snippet, refer map.entries & map.entrySet to iterate over MultiValuedMap & Map obejcts as mentioned below in data-sly-list.
<ul data-sly-list.yearsMap="${nav.map}">
<div> ${yearsMap.key} </div> ------ First level String gets printed
<ul data-sly-list.typesMap="${yearsMap.value.entrySet}">
<h1>${typesMap.key} </h1> --------Second level String gets printed
<sly data-sly-list.modelObjList="${typesMap.value}"> --------Second level Value Object List gets printed
<!--p>${modelObjList.attributeName}</p-->
</sly>
</ul>
</ul>
Hope this helps!
Hi @Nithyasri_K ,
Try with below code snippet, refer map.entries & map.entrySet to iterate over MultiValuedMap & Map obejcts as mentioned below in data-sly-list.
<ul data-sly-list.yearsMap="${nav.map}">
<div> ${yearsMap.key} </div> ------ First level String gets printed
<ul data-sly-list.typesMap="${yearsMap.value.entrySet}">
<h1>${typesMap.key} </h1> --------Second level String gets printed
<sly data-sly-list.modelObjList="${typesMap.value}"> --------Second level Value Object List gets printed
<!--p>${modelObjList.attributeName}</p-->
</sly>
</ul>
</ul>
Hope this helps!
To handle Map<String, Map<String,List<ModelObj>>>, try below code:
<div data-sly-use.nav="fragmentexamples.core.models.Nav">
<ul data-sly-list.year="${nav.map}">
<div> ${year.key} </div> ------ First level String gets printed
<ul data-sly-list.type="${year.value}">
<li>${type.key} </li> --------Second level String gets printed
<ul data-sly-list.modelObj="${type.value}">
${modelObj.modelObjProp}
</ul>
</ul>
</ul>
</div>
Regards
Praveen
Hi @Manjunath_K
Thank your for the help. Your solution worked with a slight modification as per my object.
<div data-sly-use.nav="fragmentexamples.core.models.Nav">
<ul data-sly-list.year="${nav.map.entrySet}">
<div> ${year.key}</div>
<ul data-sly-list.val="${year.value}">
<ul data-sly-list.type="${val.entrySet}">
<li>${type.key}
<ul data-sly-list.modelList="${type.value}">
<li>{modelList.modelProp}</a></li>
</ul>
</li>
</ul>
</ul>
</ul>
</div>
you're welcome
Views
Replies
Total Likes
Views
Likes
Replies