Search code examples
aemsightly

Sightly expression to compare string property with list count


I am trying to compare two values, one coming from dialog and other is count var of Map. But getting an error:

Caused by: java.lang.UnsupportedOperationException: Invalid types in comparison. Comparison is supported for Number types only

This is simple code of getting the List of links of pages, but if max count set will show restricted(max) no. of links. If three set as max count only 3 links will come in list.

<div id="${properties.containerId}" class="${properties.containerClass}">
<div data-sly-use.listOfLink="com.aem.web.core.components.ListOfLink" data-sly-unwrap>

    <div data-sly-list.keyName="${listOfLink.pageMap}" data-sly-unwrap>
        <div data-sly-test.maxcount="${properties.maxcount}" data-sly-unwrap>
        <!-- Check the max count set in dialog(property ) for link to display from Map-->
            <div data-sly-test="${keyName.count <= properties.maxcount}"  data-sly-unwrap>
                <p><a href="${keyName}">${listOfLink.pageMap[keyName][0]</a></p>
            </div>

        </div>

    </div>
</div>


Solution

  • It seems the object holding the variables is the list and not the listed item. In the link it shows an example...

    http://docs.adobe.com/docs/br/aem/6-0/develop/sightly.html#list

    <div data-sly-test="${keyNameList.count <= properties.maxcount}" data-sly-unwrap>