Boa tarde pessoal, tenho uma classe que é responsável por trazer os resultados e montar uma table em forma de relatório. Porém estou tendo problemas com a quantidade de linhas que acabam estourando memória em pcs com menos de 2gb. A solução que encontrei foi inserir uma paginação, porém não encontrei nada que pudesse me ajudar na net.
Alguém poderia me dar uma luz de como fazer isso?
Segue o código:
//AQUI É ONDE É FEITO MONTADO O RESULTADO DEPOIS NO MÉTODO ABAIXO
protected void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
Cursor crs = null;
boolean isProcess = false;
Print respPrint = new Print( response );
respPrint.initResponse();
try{
crs = getCursor(request);
Bean bean = null;
if( ( bean = ((bean)crs.next()) ) != null ){
isProcess = true;
respPrint.printParameter( "htmlCode" );
respPrint.print( "\"" );
respPrint.print( "<fieldset>" );
respPrint.print( "<table class=\'wtable\' width=\'100%\' border=\'0\'>" );
respPrint.print( getCabecalho() );
boolean par = true;
do{
respPrint.print( getConteudo( bean, ( par=!par ) ) );
bean = (Bean)crs.next();
}while( bean != null );
respPrint.print("</table>" );
respPrint.print("</fieldset>");
respPrint.print( "\"," );
}else{
respPrint.printParameter( "htmlCode" );
respPrint.print("'Informações inexistente',");
}
respPrint.printSuccess();
} catch( Exception e ) {
logError(e);
if ( isProcess ){
respPrint.print( "\"," );
}
respPrint.printParameter( "stack" );
respPrint.print( "\"" + "Erro ao gerar o relatório") + "\"," );
respPrint.printParameter( "errors" );
respPrint.print( "'" + WebUtil.getStackTrace(e) + "'," );
respPrint.faillingResponse();
} finally {
if( crs != null ) crs.close();
}
}
private String getCabecalho(){
StringBuilder cabecalho = new StringBuilder();
cabecalho.append("<tr>");
cabecalho.append( getCell( true, "COLUNA 1" ) );
cabecalho.append( getCell( true, "COLUNA 2" ) );
cabecalho.append( getCell( true, "COLUNA 3" ) );
cabecalho.append( getCell( true, "COLUNA 4" ) );
cabecalho.append("</tr>");
return( cabecalho.toString() );
}
private String getConteudo( Bean bean , boolean par ){
StringBuilder conteudo = new StringBuilder();
conteudo.append("<tr>");
conteudo.append( getCell( par, bean.getParamColuna1() ) ) ;
conteudo.append( getCell( par, bean.getParamColuna2() ) ) ;
conteudo.append( getCell( par, bean.getParamColuna3() ) ) ;
conteudo.append( getCell( par, bean.getParamColuna4() ) ) ;
conteudo.append("</tr>");
return( conteudo.toString() );
}
private String getCell( boolean par, String value ) {
String temp = ( par ? "wtcol2" : "wtcol1" );
return "<td class=\'" + temp + "\'><font class=\'" + temp + "font\'; style='padding-left:10px;text-align:left; font-weight:bold; font-size:9pt; font-family: arial;'>" + WebUtil.webAssert( value ) + "</font></td>";
}
}
Se alguém souber como ajudar fico agradecido!
Obrigado!