Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

Dynamically assign values to list iteration

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

HTL does not support typecasting.

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



Arun Patidar

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi,

HTL does not support typecasting.

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



Arun Patidar