does not work

This commit is contained in:
Zakharov_Rostislav 2024-06-10 17:19:24 +04:00
parent 8e14a128ea
commit 03044bd5a3
3 changed files with 65 additions and 6 deletions

View File

@ -3,7 +3,7 @@ package com.ip.library.core.configuration;
public class Constants {
public static final String SEQUENCE_NAME = "hibernate_sequence";
public static final int DEFUALT_PAGE_SIZE = 5;
public static final int DEFUALT_PAGE_SIZE = 2;
public static final String API_URL = "/api/1.0";

View File

@ -61,10 +61,14 @@
</tbody>
</table>
</th:block>
<th:block th:replace="~{ pagination :: pagination (
<th:block th:replace="~{ pagination :: pagination-with-params (
url=${'api/1.0/search'},
totalPages=${totalPages},
currentPage=${currentPage}) }" />
currentPage=${currentPage},
param1name=${'typeId'},
param1value=${typeId},
param2name=${'authorId'},
param2value=${authorId}) }" />
</th:block>
</main>
</body>

View File

@ -3,10 +3,10 @@
<body>
<th:block th:fragment="pagination (url, totalPages, currentPage, requestParams)">
<th:block th:fragment="pagination (url, totalPages, currentPage)">
<nav th:if="${totalPages > 1}" th:with="
maxPage=2,
currentPage=${currentPage + 1}">
maxPage=2,
currentPage=${currentPage + 1}">
<ul class="pagination justify-content-center"
th:with="
seqFrom=${currentPage - maxPage < 1 ? 1 : currentPage - maxPage},
@ -47,6 +47,61 @@
</ul>
</nav>
</th:block>
<th:block th:fragment="pagination-with-params
(url, totalPages, currentPage, param1name, param1value, param2name, param2value)">
<nav th:if="${totalPages > 1}" th:with="
maxPage=2,
currentPage=${currentPage + 1}">
<ul class="pagination justify-content-center"
th:with="
seqFrom=${currentPage - maxPage < 1 ? 1 : currentPage - maxPage},
seqTo=${currentPage + maxPage > totalPages ? totalPages : currentPage + maxPage}">
<th:block th:if="${currentPage > maxPage + 1}">
<li class="page-item">
<a class="page-link" aria-label="Previous"
th:href="@{/{url}?page=0&{param1name}={param1value}&{param2name}={param2value}
(url=${url},
param1name=${param1name},param1value=${param1value},
param2name=${param2name},param2value=${param2value})}">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li class="page-item disabled">
<span class="page-link" aria-label="Previous">
<span aria-hidden="true">&hellip;</span>
</span>
</li>
</th:block>
<li class="page-item" th:each="page : ${#numbers.sequence(seqFrom, seqTo)}"
th:classappend="${page == currentPage} ? 'active' : ''">
<a class=" page-link"
th:href="@{/{url}?page={page}&{param1name}={param1value}&{param2name}={param2value}
(url=${url},page=${page - 1},
param1name=${param1name},param1value=${param1value},
param2name=${param2name},param2value=${param2value})}">
<span th:text="${page}" />
</a>
</li>
<th:block th:if="${currentPage < totalPages - maxPage}">
<li class="page-item disabled">
<span class="page-link" aria-label="Previous">
<span aria-hidden="true">&hellip;</span>
</span>
</li>
<li class="page-item">
<a class="page-link" aria-label="Next"
th:href="@{/{url}?page={page}&{param1name}={param1value}&{param2name}={param2value}
(url=${url},page=${totalPages - 1},
param1name=${param1name},param1value=${param1value},
param2name=${param2name},param2value=${param2value})}">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</th:block>
</ul>
</nav>
</th:block>
</body>