Paginação para MVC com JSTL estilo WORDPRESS

0 respostas
charlesalmeida

Olá,

Alguém poderia me ajudar demonstrando um exemplo de paginação para ser usado interagindo com controller passando com jstl ?
pesquisei e encontrei esse exemplo mas ele trabalha com dados da memoria e ainda fixa eixo X e Y para paginar.

Gostaria de Exemplo feito com JSTL com paginação estilo WORDPRESS.

Que recebesse e paginasse de forma simples :
.TOTAL REGISTROS:
.LISTA DE REGISTROS:

<!-- Start : Initialize Pagination -->

<!-- Define Page Size ( Actually I initialize pageSize value from properties ) -->
<c:set value="3" var="pageSize"/> 

<!--
	  Look for parameters s & e (represents start and end)
	  If not found then set them to default values
-->

	<c:choose>
		<c:when test="${empty param.s}">
			<c:set var="rowStart" value="1"/>
		</c:when>
		<c:otherwise>
			<c:set var="rowStart" value="${param.s}"/>
		</c:otherwise>
	</c:choose>

	<c:choose>
		<c:when test="${empty param.e}">
			<c:set var="rowEnd" value="${pageSize}"/>
		</c:when>
		<c:otherwise>
			<c:set var="rowEnd" value="${param.e}"/>
		</c:otherwise>
	</c:choose>

<!-- End : Initialize Pagination -->

<!-- Whats important is below declaration. You know what I mean
	 begin="${rowStart-1}" step="1" end="${rowEnd-1}"
-->



<br>
<c:forEach begin="${rowStart-1}" step="1" end="${rowEnd-1}" var="usuario" varStatus="status" items="${usuarioList}">
<tr>
	<td>${status.count}</td>
	<td>${usuario.nome}</td>
	
</tr>
<br>
</c:forEach>
<br>
<br>
<!-- Now begins the display of page navigation. I planned to display like this

     [ Showning X/Y of N records ]  <PREV 1..............N NEXT>

	 Dont bother about the url values. All you need to do is ensure you pass parameters to this page back
 -->

<c:set value="${total}" var="rLen"/>

<c:choose>
	<c:when test="${rLen lt rowEnd}">
		<c:set var="rCurrEnd" value="${rLen}"/>
	</c:when>
	<c:otherwise>
		<c:set var="rCurrEnd" value="${rowEnd}"/>
	</c:otherwise>
</c:choose>


	 Mostrando ${rowStart}/${rCurrEnd} de ${rLen}
	
<br>
<br>
		<c:if test="${rowStart gt 1}">
			<c:url value="/usuario?s=${rowStart-pageSize}&e=${rowEnd-pageSize}" var="urlPrev"/>
			<a href="${urlPrev}"> < Anterior </a>
		</c:if>

		<c:forEach var="pStart" varStatus="status" begin="0" end="${rLen-1}" step="${pageSize}">
			<c:url value="/usuario?s=${pStart+1}&e=${pStart+pageSize}" var="urlCurr"/>
			<span>
				<a href="${urlCurr}"> ${status.count} </a>
			</span>
		</c:forEach>

		<c:if test="${rowEnd lt rLen}">
			<c:url value="/usuario?s=${rowStart+pageSize}&e=${rowEnd+pageSize}" var="urlNext"/>
			<a href="${urlNext}">Proximo ></a>
		</c:if>


Criado 8 de janeiro de 2012
Respostas 0
Participantes 1