Paginação + Struts

Olá pessoal,
Alguém sabe uma forma prática de fazer paginação com struts…

Abraços,

Nada te impede de usar a displaytag com Struts:

http://displaytag.homeip.net/displaytag-examples-1.1/example-paging.jsp

Ex:

public ActionForward execute(ActionMapping map, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		RelatorioForm formulario = (RelatorioForm) form;
		RelatorioDAO relatorios = new RelatorioDAO();

		if (formulario.getAcao().equalsIgnoreCase("Gerar")) {
			request.setAttribute("relatorios", relatorios.getLista(formulario));
			return map.findForward("ok");

Passa uma lista por request e a taglib se vira e monta:

//JSP

<display:table requestURI="Relatorio.do?acao=Gerar" name="${relatorios}" uid="relatorio" class="its" pagesize="20" export="true">
<display:column property="codigo" title="Id" href="Relatorio.do?acao=Obter" paramId="codigo" paramProperty="codigo" sortable="true"/>
<display:column property="dateStart" title="Date Start" sortable="true"/>
<display:column property="events" title="Events" sortable="true"/>
<display:column property="ani" title="ANI" sortable="true"/>
<display:column property="extension" title="Extension" sortable="true"/>
<display:column property="status" title="Status" sortable="true"/>
<display:column property="agentId" title="Agent Id" sortable="true"/>
</display:table>

Olá Pedro,
Já usei uma vez o displaytag(muito bom), mas nesse caso preciso paginar em várias requisições, trazendo 10 registros da base a cada vez que clico next…

Obrigado pela ajuda!

Olá pessoal,
Fiz uma paginação com jsptags, funcionou blza, mas não consigo atualizar o link da página quando volta da consulta, ou seja, na série de links 1,2,3, supondo que cliquei no 2, quando a action retornar para a página novamente precisava ter a variável currentPage atualizada…

Segue o código da jsp, obrigado desde já!

8888888888888888888888888888888888888888888888888888888888888

<%@ page language=“java” contentType=“text/html; charset=ISO-8859-1” pageEncoding=“ISO-8859-1”%>

<%@ taglib uri="/tags/struts-tiles" prefix=“tiles”%>
<%@ taglib uri="/tags/struts-html" prefix=“html”%>
<%@ taglib uri="/tags/struts-bean" prefix=“bean”%>
<%@ taglib uri="/tags/struts-logic" prefix=“logic”%>
<%@ taglib uri=“http://jsptags.com/tags/navigation/pager” prefix=“pg” %>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>

<html>
<head>
</head>

<%-- %>ENCONTRADOS: <bean:write name=“paginacao” property=“registrosEncontrados”/>
TOTAL POR PÁGINA: <bean:write name=“paginacao” property=“registrosPorPagina”/>
PÁGINA SOLICITADA: <bean:write name=“paginacao” property=“paginaSolicitada”/>
outro<bean:write name=“paginacao” property=“action”/>–%&gt

<%
String style = “simple”;
String position = “top”;
String index = “center”;

//Informações para paginação
br.com.shc.infra.Paginacao paginacao = (br.com.shc.infra.Paginacao) request.getAttribute("paginacao");
Integer maxPageItems = paginacao.getRegistrosPorPagina();
Integer maxIndexPages = paginacao.getLinksPorPagina();
Integer items = paginacao.getRegistrosEncontrados();

%>
<%–out.print(“tamanho do list: “+ ((java.util.List)request.getAttribute(“listPesquisaTodosSerHumanoForm”)).size());–%>
<pg:pager
items=”<%= items %>”
index="<%= index %>"
maxPageItems="<%= maxPageItems %>"
maxIndexPages="<%= maxIndexPages %>"
isOffset="<%= true %>"
export=“offset,currentPageNumber=pageNumber”
scope=“request”>

<%-- keep track of preference --%>
<pg:param name=“style”/>
<pg:param name=“position”/>
<pg:param name=“index”/>
<pg:param name=“maxPageItems”/>
<pg:param name=“maxIndexPages”/>

<pg:param name=“action” value=“search”/>

<input type=“hidden” name=“pager.offset” value="<%= offset %>">

<table width=“458” border=“0”>
<tr align=“center” class=“tabledesubacao”><td> Registros Encontados: <%=paginacao.getRegistrosEncontrados()%></td></tr>
<tr align=“center” class=“tabledesubacao”>
<td>
<pg:prev export=“pageUrl”> [<< Prev]</pg:prev>
<pg:pages>
<%
// if (pageNumber.intValue() < 10) {
if (pageNumber.intValue() < 10) {
%> <%
}
if (pageNumber == currentPageNumber) {
%><%= pageNumber %><%
} else {
%><%=pageNumber%><%
}
%>
</pg:pages>
<pg:next export=“pageUrl”> [Next >>]</pg:next>
</td>
</tr>
</table>

<body leftmargin=“0” topmargin=“0” rightmargin=“0” bottommargin=“0” marginwidth=“0” marginheight=“0”>
<table width=“458” border=“0” cellpadding=“0” cellspacing=“0” class=“table”>
<tr class=“tableTitulo”>
<td colspan=“3”>
 <bean:message key=“serhumano.titulo”/>
</td>
</tr>
<tr class=“tabledesubacao”>
<td width=“209”>
 <bean:message key=“b2.nome”/></td>
<td width=“209”>
<bean:message key=“b2.data”/></td>
<td width=“40”>
<div align=“center”>
<bean:message key=“b2.acao”/>
</div>
</td>
</tr>
<tr align=“right”>
<td colspan=“3”>
<table width=“458” class=“linhasAlternadas” border=“0” cellspacing=“0” cellpadding=“0”>
<logic:iterate name=“listPesquisaTodosSerHumanoForm” id=“humano”>
<logic:equal name=“humano” property=“linha” value=“A”>
<tr class=“even”>
</logic:equal>
<logic:equal name=“humano” property=“linha” value=“B”>
<tr>
</logic:equal>
<td width=“209”>
<a humano" />&acao=P"&gt
<bean:write name=“humano” property=“nomeHumano”/>

</td>
<td width=“209” class=“even”>
<bean:write name=“humano” property=“dataNascimentoHumano”/>
</td>
<td width=“40”>
<div align=“center”>
<input alt=“Excluir” src=“images/garbage.gif” name=“image” type=“image” type=“button” value=“Excluir”
style=“font-size:11px” onClick=“excluir(’<bean:write name=“humano” property=“idHumano”/>’);”&gt
</div>
</td>
</tr>
</logic:iterate>
</table>
</pg:pager>
<%-- CONTROLE DE FORMULARIO --%>
<script>
function excluir(id)
{
if(confirm(‘Confirma Exclusão?’))
{
document.location.href=’<bean:write name=“excluir”/>?id=’+id;
}
}
</script>
</td>
</tr>
<tr class=“tableInterna2” align=“right”>
<td colspan=“3”>
<tiles:insert page=“buttonIncluirSair.jsp”/>
</td>
</tr>
</table>
</body>
</html>