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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Dynamically assign values to list iteration

majohns0321
Level 1
Level 1

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?

htl list
1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

HTL does not support typecasting.

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

View solution in original post

1 Reply
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

HTL does not support typecasting.

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

View solution in original post