Dynamically assign values to list iteration

Avatar

Avatar
Level 1
majohns0321
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
majohns0321
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
View profile
majohns0321
Level 1

19-07-2021

How can I dynamically assign iteration values to a list? I would like to use parameter values sent in from the URL to iterate specific parts of a list of articles. 

 

This is the code I am working with -- and it is return the error below the code: 


"<sly data-sly-set.listStart="${request.parameterMap.start}"/>
<sly data-sly-set.listEnd="${request.parameterMap.end}"/>

<ul data-sly-use.list="com.adobe.cq.wcm.core.components.models.List"
    data-sly-list.item="${list.listItems @ begin=listStart, step = 1 ,end=listEnd}"
    data-sly-use.template="core/wcm/components/commons/v1/templates.html"
    data-sly-use.itemTemplate="item.html"
    data-sly-test.itemType="${properties.itemType ? properties.itemType : 'item'}"
    class="cmp-list paginatedList">
    <sly data-sly-call="${itemTemplate[itemType] @ list = list, item = item}"></sly>
</ul>"

"org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: Operands are not of the same type: comparison is supported for Number types only."

 

Is there a way to assign a numeric data type in HTL?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

20-07-2021

Hi,

HTL does not support typecasting.

You need to write a java to get integer values from the Sling Model.

Answers (0)