Problems when getting the index or count on data-sly-list | Community
Skip to main content
francisco_ribei
New Participant
October 16, 2015
Solved

Problems when getting the index or count on data-sly-list

  • October 16, 2015
  • 12 replies
  • 5689 views

Hi,

I'm using sightly with a Java class annotated with @Model.

And the class has a method that return a list with objects. Like List<CarouselPage> pages;

I can iterate over the list and get the object properties, but when I try ${itemList.count} or ${itemList.index} it throws an error:

Caused by: io.sightly.java.compiler.CompilerException: Compilation errors in apps/<mysite>/components/content/carousel/SightlyJava_carousel.java:
Line 79, column 4018 : Cannot invoke equals(boolean) on the primitive type long
    at io.sightly.java.compiler.SightlyCompileServiceImpl.compileJavaResource(SightlyCompileServiceImpl.java:187)
    at io.sightly.java.compiler.SightlyCompileServiceImpl.compileSource(SightlyCompileServiceImpl.java:132)

I thought it was a problem wiht List itself, then I tried returning the iterator instead of the List, but I got the same problem. 

But when I try with the iterator returned by currentPage.listChildren the index and cound works.

Did you guys already faced this problem?

Follow the code:

<ul data-sly-list="${currentPage.listChildren}"> <li>${itemList.index} - ${item.title}</li> </ul> <ol class="carousel-indicators" data-sly-list="${carousel.pages}"> <li data-target="#main-slider" data-slide-to="${itemList.index}" class=""></li> </ol>
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

With the attribute I mean data-slide-to="", instead of <li>${itemList.index}</li>

12 replies

Feike_Visser1
Feike_Visser1Accepted solution
Employee
October 16, 2015

With the attribute I mean data-slide-to="", instead of <li>${itemList.index}</li>

francisco_ribei
New Participant
October 16, 2015

Ahh!! got it!!! smiley

Thanks you so much!!