pagination.tag 4.48 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<%@ tag description="Display pagination" pageEncoding="UTF-8" %>
<%@ tag body-content="empty" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ attribute name="pagedData" required="true" type="org.springframework.data.domain.Page" %>
<%@ attribute name="jsonFilter" required="true" type="java.lang.String" %>

<nav class="text-center pull-left">
    <form method="get" action="">
        <ul class="pagination pagination-lg">
            <li>
                 <span class="results">
                     <spring:message code="accessions.number" arguments="${pagedData.totalElements}"/>
                 </span>
            </li>
17
18
19
20
21
22
23
24
25
26
27
28
29
30
            <c:if test="${pagedData.number eq 0}">
                <li class="disabled">
                    <span class="firstPage" aria-label="<spring:message code="pagination.previous-page" />">
                        <span aria-hidden="true">&laquo;</span>
                    </span>
                </li>
                <li class="disabled">
                    <span class="previousPage" aria-label="<spring:message code="pagination.previous-page" />">
                        <span aria-hidden="true">&lsaquo;</span>
                    </span>
                </li>
            </c:if>
            <c:if test="${pagedData.number gt 0}">
                <li>
Matija Obreza's avatar
Matija Obreza committed
31
                 <span aria-label="<spring:message code="pagination.previous-page" />" class="firstPage">
32
                     <span aria-hidden="true">
33
                         <a href="<spring:url value=""><spring:param name="page" value="1" /><spring:param name="filter" value="${jsonFilter}" /></spring:url>">&laquo;</a>
34
35
                     </span>
                 </span>
36
37
                </li>
                <li>
Matija Obreza's avatar
Matija Obreza committed
38
                 <span aria-label="<spring:message code="pagination.previous-page" />" class="previousPage">
39
                     <span aria-hidden="true">
40
                         <a href="<spring:url value=""><spring:param name="page" value="${pagedData.number eq 0 ? 1 : pagedData.number}" /><spring:param name="filter" value="${jsonFilter}" /></spring:url>">&lsaquo;</a>
41
42
                     </span>
                 </span>
43
44
                </li>
            </c:if>
45
46
            <li>
                 <span class="pagination-input">
47
                     <input class="form-control" id="paginationInputField" style="display: inline; max-width: 5em; text-align: center" type="text" name="page" value="${pagedData.number + 1}"/>
48
49
                 </span>
            </li>
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
            <c:if test="${pagedData.number ge pagedData.totalPages-1}">
                <li class="disabled">
                    <span class="nextPage" aria-label="<spring:message code="pagination.next-page" />">
                         <span aria-hidden="true">&rsaquo;</span>
                    </span>
                </li>
                <li class="disabled">
                    <span class="lastPage" aria-label="<spring:message code="pagination.next-page" />">
                        <span aria-hidden="true">&raquo;</span>
                    </span>
                </li>
            </c:if>
            <c:if test="${pagedData.number lt pagedData.totalPages-1}">
                <li>
                     <span aria-label="<spring:message code="pagination.next-page" />" class="nextPage">
                         <span aria-hidden="true">
                             <a href="<spring:url value=""><spring:param name="page" value="${pagedData.number + 2}" /><spring:param name="filter" value="${jsonFilter}" /></spring:url>">&rsaquo;</a>
                         </span>
68
                     </span>
69
70
71
72
73
74
                </li>
                <li>
                     <span aria-label="<spring:message code="pagination.next-page" />" class="lastPage">
                         <span aria-hidden="true">
                             <a href="<spring:url value=""><spring:param name="page" value="${pagedData.totalPages}" /><spring:param name="filter" value="${jsonFilter}" /></spring:url>">&raquo;</a>
                         </span>
75
                     </span>
76
77
                </li>
            </c:if>
78
79
80
81
82
83
84
85
86
            <li>
                 <span class="totalPages">
                     <spring:message code="paged.ofPages" arguments="${pagedData.totalPages}"/>
                 </span>
            </li>
        </ul>
        <input type="hidden" name="filter" value="<c:out value="${jsonFilter}" />"/>
    </form>
</nav>