Progress while filling jasper report

2019-02-09 10:28发布

问题:

I would like to give progress to the user while Jasper reports is filling a compile report. Basically I would like to get progress while this is executing:

JasperFillManager.fillReport(JasperReport rpt, Map params, JRDataSource src)

Is there anyway to achieve this?

回答1:

From Jasper Reports version 4.6.0 You can use FillListener:

AsynchronousFillHandle handle = AsynchronousFillHandle.createHandle(jasperReport, params, dataSource);
handle.addFillListener(new FillListener() {

    @Override
    public void pageUpdated(JasperPrint jasperPrint, int pageIndex) {
        log.info("pageUpdated " + pageIndex);
    }

    @Override
    public void pageGenerated(JasperPrint jasperPrint, int pageIndex) {
        log.info("pageGenerated " + pageIndex);
    }
});

NOTE: to build 4.6.0 version get sources from svn and use ant:

svn co http://jasperforge.org/svn/repos/jasperreports (user/pass: anonymous)
cd jasperreports\trunk\jasperreports
ant jar


回答2:

I'm using this components from PrimeFaces to show that the report is generating:

<p:ajaxStatus onstart="dlg.show();" onsuccess="dlg.hide();" />
        <p:dialog modal="true"  header="Creating Report" widgetVar="dlg" draggable="false" closable="false" >
            <p:graphicImage value="/resources/images/ajaxloadingbar.gif" />
        </p:dialog>

I don't have any real way to determine the total time my reports will take to compile and fill, so I opted not to use an actual progress bar which sometimes fills before the report is complete.



回答3:

I'm afraid it's not possible to monitor progress of filling jasper report (as of version 4.0.2)- net.sf.jasperreports.engine.fill.JRFiller doesn't offer any kind of progress notification.