RNJ
RNJ

Reputation: 15572

Accessing a for loop variable inside and if statement

I have the following code but it gives me an error. Can anyone help?

<span th:each="p,iter : ${pp}">
    <span th:text="${p.title}">[default]</span>
    <span
                  th:if="${#lists.size(hh) >= iter.index
                  th:text="${hh[iter.index].name}">
    </span>
  ...

I get this error message:

Error during execution of processor org.thymeleaf.standard.processor.attr.StandardIfAttrProcessor'

It is because of the list.size(hh) >= iterStat.index. If I don't have the iterStat.index then it is ok. But as this is dynamic I want to use the index of the iteration.

Is this possible?

Upvotes: 0

Views: 586

Answers (1)

Jad B.
Jad B.

Reputation: 1483

You have a missing } in th:if="${#lists.size(hh) >= iter.index

Upvotes: 2

Related Questions