Search in sources :

Example 1 with AsyncJasperPrintAccessor

use of net.sf.jasperreports.web.servlets.AsyncJasperPrintAccessor in project VaadinUtils by rlsutton1.

the class JasperManager method fillReport.

// /**
// * Binds a value to a report parameter.
// *
// * Essentially a report can have a no. of named parameters which are used
// to
// * filter the report or display on the report. This method allows you to
// * pass in a map (name, value) of parameter value at runtime.
// *
// * @param parameters
// * a map of name/value pairs to bind to report parameters of the
// * given names.
// */
// 
// private void bindParameters(Map<String, Object> parameters)
// {
// for (String parameterName : parameters.keySet())
// {
// Preconditions.checkArgument(paramExists(parameterName),
// "The passed Jasper Report parameter: "
// + parameterName + " does not existing on the Report");
// 
// boundParams.put(parameterName, parameters.get(parameterName));
// }
// }
private JasperPrint fillReport(OutputFormat outputFormat) throws JRException, InterruptedException {
    Connection connection = reportProperties.getConnection();
    fillHandle = CustomAsynchronousFillHandle.createCustomHandle(jasperReport, boundParams, connection);
    fillHandle.setDataProvider(reportProperties, outputFormat);
    fillHandle.addFillListener(new FillListener() {

        @Override
        public void pageUpdated(JasperPrint jasperPrint, int pageIndex) {
            queueEntry.setStatus("Filling page " + pageIndex);
        }

        @Override
        public void pageGenerated(JasperPrint jasperPrint, int pageIndex) {
            queueEntry.setStatus("Generating page " + pageIndex);
        }
    });
    AsyncJasperPrintAccessor asyncAccessor = new AsyncJasperPrintAccessor(fillHandle);
    if (!stop) {
        fillHandle.startFill();
    }
    // boundParams, connection);
    while (asyncAccessor.getReportStatus().getStatus() == ReportExecutionStatus.Status.RUNNING) {
        Thread.sleep(100);
    }
    return asyncAccessor.getFinalJasperPrint();
}
Also used : AsyncJasperPrintAccessor(net.sf.jasperreports.web.servlets.AsyncJasperPrintAccessor) FillListener(net.sf.jasperreports.engine.fill.FillListener) JasperPrint(net.sf.jasperreports.engine.JasperPrint) Connection(java.sql.Connection) JasperPrint(net.sf.jasperreports.engine.JasperPrint)

Aggregations

Connection (java.sql.Connection)1 JasperPrint (net.sf.jasperreports.engine.JasperPrint)1 FillListener (net.sf.jasperreports.engine.fill.FillListener)1 AsyncJasperPrintAccessor (net.sf.jasperreports.web.servlets.AsyncJasperPrintAccessor)1