내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Sightly List size

Avatar

Level 2

Hi all,

I have used list of child page using Sightly but i want to get the size of that list.

<Sly data-sly-list=${current page.listChildren}>

I want size , i tried itemList.size and item list.length

But it is not working.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi,

HTL does not provide any method to get list size.

https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#226-list  

 

I would recommend to use java suggested by @ksh_ingole7 

 

But If you are curious about how to do it in HTL, I can tell but this is not an optimal solution, you may end up parsing list twice.

 

<sly data-sly-list="${currentPage.listChildren}">
	<sly data-sly-test="${itemList.last}" data-sly-set.aListSize="${itemList.count}" />
</sly>
List size is : ${aListSize}
Arun Patidar

AEM LinksLinkedIn

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Community Advisor

Hey @bangar20 

 

Consider the following example and see the text in bold :

 

In java:-

 

public List getTestList() {

return testList;

}

 

In HTML:-

 

<sly data-sly-use.useClassObj = "com.ups.components.use.ArrayListClassUse">

Size of List:- ${useClassObj .testList.size}

</sly>

 

Call the getTestList() method using the Class object and the do .size. This will return the size of the list. 

 

Thanks

Avatar

Level 2

Hi @ksh_ingole7 ,

I know from java end but i need to do from Sightly object because I am fetching the list from Sightly object.

 

 

 

Avatar

정확한 답변 작성자:
Community Advisor

Hi,

HTL does not provide any method to get list size.

https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#226-list  

 

I would recommend to use java suggested by @ksh_ingole7 

 

But If you are curious about how to do it in HTL, I can tell but this is not an optimal solution, you may end up parsing list twice.

 

<sly data-sly-list="${currentPage.listChildren}">
	<sly data-sly-test="${itemList.last}" data-sly-set.aListSize="${itemList.count}" />
</sly>
List size is : ${aListSize}
Arun Patidar

AEM LinksLinkedIn