diff options
author | Maria Odea B. Ching <oching@apache.org> | 2008-07-11 07:51:47 +0000 |
---|---|---|
committer | Maria Odea B. Ching <oching@apache.org> | 2008-07-11 07:51:47 +0000 |
commit | 60b94edc695ec06f7055382f50b3310d546fdf6f (patch) | |
tree | d3583467aa5429da82121402c297be9319f9023e | |
parent | 6f322f77cea289961aa1891266faf136dd482026 (diff) | |
download | archiva-60b94edc695ec06f7055382f50b3310d546fdf6f.tar.gz archiva-60b94edc695ec06f7055382f50b3310d546fdf6f.zip |
[MRM-861]
-fixed up the number links in the pagination
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@675852 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp index 3217ccd3f..3bd47cbd3 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp @@ -50,8 +50,14 @@ <%-- search was made from the indices --%> <c:when test="${databaseResults == null}"> <c:set var="hitsNum">${fn:length(results.hits) + (currentPage * results.limits.pageSize)}</c:set> - <p>Hits: ${(hitsNum - results.limits.pageSize) + 1} to ${hitsNum} of ${results.totalHits}</p> - + <c:choose> + <c:when test="${results.totalHits > results.limits.pageSize}"> + <p>Hits: ${(hitsNum - results.limits.pageSize) + 1} to ${hitsNum} of ${results.totalHits}</p> + </c:when> + <c:otherwise> + <p>Hits: 1 to ${hitsNum} of ${results.totalHits}</p> + </c:otherwise> + </c:choose> <c:choose> <c:when test="${empty results.hits}"> <p>No results</p> @@ -84,10 +90,34 @@ </a> </c:otherwise> </c:choose> - - <c:forEach var="i" begin="0" end="${totalPages - 1}"> - <c:choose> - <c:when test="${ (i != currentPage) }"> + + <%-- Google-style pagination --%> + <c:choose> + <c:when test="${totalPages > 11}"> + <c:choose> + <c:when test="${(currentPage - 5) < 0}"> + <c:set var="beginVal">0</c:set> + <c:set var="endVal">10</c:set> + </c:when> + <c:when test="${(currentPage + 5) > (totalPages - 1)}"> + <c:set var="beginVal">${(totalPages -1) - 10}</c:set> + <c:set var="endVal">${totalPages - 1}</c:set> + </c:when> + <c:otherwise> + <c:set var="beginVal">${currentPage - 5}</c:set> + <c:set var="endVal">${currentPage + 5}</c:set> + </c:otherwise> + </c:choose> + </c:when> + <c:otherwise> + <c:set var="beginVal">0</c:set> + <c:set var="endVal">${totalPages - 1}</c:set> + </c:otherwise> + </c:choose> + + <c:forEach var="i" begin="${beginVal}" end="${endVal}"> + <c:choose> + <c:when test="${i != currentPage}"> <c:set var="specificPageUrl"> <ww:url action="quickSearch" namespace="/"> <ww:param name="q" value="%{'${q}'}"/> @@ -98,12 +128,12 @@ </c:when> <c:otherwise> <b>${i + 1}</b> - </c:otherwise> - </c:choose> + </c:otherwise> + </c:choose> </c:forEach> - + <c:choose> - <c:when test="${ currentPage eq ( totalPages - 1 ) }"> + <c:when test="${currentPage == (totalPages - 1)}"> <img src="${imgNextPageDisabledUrl}"/> </c:when> <c:otherwise> |