Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Get props in List of List of Object based on Specific Index in Sightly


Level 3

Hello All,

I have a list which I call rows here, then inside that I have another list which is list itself, but I want to get specific index of that list based on outer list index.(rowsList.index), after that I will get the objects inside inner list to show props.

But it is not going inside   <sly data-sly-list.singleList="${logic.listOLists[rowsList.index]}">

I have these two list in my service:

public ArrayList<ArrayList<List<MyObject>>> listOfLists = new ArrayList<ArrayList<List<MyObject>>>();
public ArrayList<List<MyObject>> singleList = new ArrayList<List<MyObject>>();

each item of singleList is like this:

public List<MyObject> myObject = new ArrayList<>();

How should I get inside that listOfLists based on index of outter list?

What is exactly method I need to make sure it will get name/label/required from myobject?

I know that service is adding correctly to the "listOfLists" and "singleList".

Here is part of my sightly.

<div data-sly-use.logic="xx.xx.model.searchRows">


     <sly data-sly-list.rows="${logic.selectedRows}">



                    <input type="text" id="name" name="name" value=${}>



                     <sly data-sly-list.singleList="${logic.listOfLists[rowsList.index]}">

                            <sly data-sly-list.innerList="${singleList.listChildren}">

                                 <h2>${} - ${innerList.label} - ${innerList.href}</h2>








Thanks for your time.

1 Accepted Solution


Correct answer by
Level 10

Are you basing this on a SLING MODEL -where you know your collections are properly set?

View solution in original post

4 Replies


Level 3

In sightly I have created another template and pass parameter to the next template.

Still no luck to get list of list based on index which is passing correctly!

<sly data-sly-test.listOfLists="${logic.listOfLists}">
  <div data-sly-use.infoTemplate="info.html">
  <sly data-sly-call="${infoTemplate.renderInfo @
                      logic=logic, i=rowsList.index, listOfLists=listOfLists}" />


<template data-sly-template.renderInfo="${ @ logic, i, listOfLists}">
  <sly data-sly-test="${listOfLists.size > 0 && i < listOfLists.size}"> ====> It is passing this line
  <sly data-sly-test.singleList="${listOfLists[i]}"> ======> This one doesn't pass!!

Any Idea why listOfLists[i] is not returning singleList?!


Correct answer by
Level 10

Are you basing this on a SLING MODEL -where you know your collections are properly set?


Level 3

Yes, I know the property has been set correctly. In service I have while loop with these:


And they have set values which I can see in the logs/debugger & size of each list are same as my db correctly.

My only problem is why I can't get listofLists[i] here!


Level 3

I have done some changes in my model and add id manually, and I guess I am close to get my result. At least I could get the list based on index. thank you.