Preventing block of Thymeleaf to run

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Preventing block of Thymeleaf to run

xpro
The code below is for a classifieds like website that takes care of pagation. Right now if the city page has no ads I get the following error.


There was an unexpected error (type=Internal Server Error, status=500).
Exception evaluating SpringEL expression: "#numbers.sequence(pager.startPage, pager.endPage)" (city:74)


Is there a block style if statement in Thymeleaf so I can prevent anything from pagation to run if no ads exists for that city?


<div class="row">
    <div th:if="${ads.totalPages != 1}"
        class="form-group col-md-11 pagination-centered">
        <ul class="pagination">
            <li th:class="${ads.number == 0} ? disabled"><a
                class="pageLink" th:href="1">&laquo;</a></li>
            <li th:class="${ads.number == 0} ? disabled"><a
                class="pageLink" th:href="${ads.number}">&larr;</a></li>
            <li
                th:class="${ads.number == (page - 1)} ? 'active pointer-disabled'"
                th:each="page : ${#numbers.sequence(pager.startPage, pager.endPage)}">
                <a class="pageLink"
                th:href="@{${'/' + cityForPage + '/{page}'}(page=${page})}"
                th:text="${page}"></a>
            </li>
            <li th:class="${ads.number + 1 == ads.totalPages} ? disabled">
                <a class="pageLink"
                th:href="@{${'/' + cityForPage + '/{page}'}(page=${ads.number + 2})}">&rarr;</a>
            </li>
            <li th:class="${ads.number + 1 == ads.totalPages} ? disabled">
                <a class="pageLink"
                th:href="@{${'/' + cityForPage + '/{page}'}(page=${ads.totalPages})}">&raquo;</a>
            </li>
        </ul>
    </div>
</div>