# Revision history [back]

Hey all!

I'm running into a problem with exporting a jasperreport object as a PDF using MVVM.

The general idea is that I have a jasperreport, which works fine. But I also have a series of buttons to export said report in various formats. Here is a snippet from the .zul:

<vbox width="100%" align="right" id="buttonbar">
<hbox width="160px" height="40px" align="right">
id="pdfReport" image="/images
/pdf_ico.jpg"/>
</hbox>
</vbox>


Pretty straight forward, and the initial jasperreport looks great. But the export is what I'm having problems with.

 @Command

}


This worked nicely when using MVC, so I figured it would work using MVVM. However, all I get are empty PDF documents.

Suggestions?

Hey all!

I'm running into a problem with exporting a jasperreport object as a PDF using MVVM.

The general idea is that I have a jasperreport, which works fine. But I also have a series of buttons to export said report in various formats. Here is a snippet from the .zul:

<vbox width="100%" align="right" id="buttonbar">
<hbox width="160px" height="40px" align="right">
id="pdfReport" image="/images
/pdf_ico.jpg"/>
</hbox>
</vbox>


Pretty straight forward, and the initial jasperreport looks great. But the export is what I'm having problems with.

 @Command
"reportType"})

}


This worked nicely when using MVC, so I figured it would work using MVVM. However, all I get are empty PDF documents.

Suggestions?

Hey all!

I'm running into a problem with exporting a jasperreport object as a PDF using MVVM.

The general idea is that I have a jasperreport, which works fine. But I also have a series of buttons to export said report in various formats. Here is a snippet from the .zul:

<vbox width="100%" align="right" id="buttonbar">
<hbox width="160px" height="40px" align="right">
id="pdfReport" image="/images
/pdf_ico.jpg"/>
</hbox>
</vbox>


Pretty straight forward, and the initial jasperreport looks great. But the export is what I'm having problems with.

 @Command
@NotifyChange({"dlReportSource", "reportType"})

}


This worked nicely when using MVC, so I figured it would work using MVVM. However, all I get are empty PDF documents.

Suggestions?

Hey all!

I'm running into a problem with exporting a jasperreport object as a PDF using MVVM.

The general idea is that I have a jasperreport, which works fine. But I also have a series of buttons to export said report in various formats. Here is a snippet from the .zul:

<vbox width="100%" align="right" id="buttonbar">
<hbox width="160px" height="40px" align="right">
id="pdfReport" image="/images
/pdf_ico.jpg"/>
</hbox>
</vbox>


Pretty straight forward, and the initial jasperreport looks great. But the export is what I'm having problems with.

 @Command

}


This worked nicely when using MVC, so I figured it would work using MVVM. However, all I get are empty PDF documents.

Suggestions?

Hey all!

I'm running into a problem with exporting a jasperreport object as a PDF using MVVM.

The general idea is that I have a jasperreport, which works fine. But I also have a series of buttons to export said report in various formats. Here is a snippet from the .zul:

<vbox width="100%" align="right" id="buttonbar">
<hbox width="160px" height="40px" align="right">
id="pdfReport" image="/images
/pdf_ico.jpg"/>
</hbox>
</vbox>


Pretty straight forward, and the initial jasperreport looks great. But the export is what I'm having problems with.

 @Command

}


This worked nicely when using MVC, so I figured it would work using MVVM. However, all I get are empty PDF documents.

Suggestions?

Edit: At sjoshi's suggestion, I tried populating with the jasperPrint object, my resulting code is as follows: JRDataSource ds = datasource; ByteArrayOutputStream output = new ByteArrayOutputStream(); try { JasperPrint jasperPrint = JasperFillManager.fillReport(Executions.getCurrent().getDesktop().getWebApp().getRealPath("/") + "statementTemplate.jasper", parameters, ds); byte[] ba = JasperExportManager.exportReportToPdf(jasperPrint); System.out.println("bytestream: " + ba.length); Filedownload.save(ba, reportDownload.getReport().getContentType(), selectedStatement.getFullDate().getValue()+"." + reportDownload.getReport().getContentType()); } catch (JRException e) { // TODO Auto-generated catch block e.printStackTrace(); }

This gave me the same issue of blank documents, but on further inspection I'm seeing that the byte array is ending up nearly empty, even though the datasource has 33 records. The byte array should have a length of about 59k. So I think the source of the problem is somewhere with the application of the datasource to the report, a step missing or something.

Is there something that goes on in the background between a jasperreport object being populated with data and it being displayed in a <jasperreport> tag? I'm not doing that with this MVVM setup, but my guess would be that something is missing there.

 6 No.6 Revision

Hey all!

I'm running into a problem with exporting a jasperreport object as a PDF using MVVM.

The general idea is that I have a jasperreport, which works fine. But I also have a series of buttons to export said report in various formats. Here is a snippet from the .zul:

<vbox width="100%" align="right" id="buttonbar">
<hbox width="160px" height="40px" align="right">
id="pdfReport" image="/images
/pdf_ico.jpg"/>
</hbox>
</vbox>


Pretty straight forward, and the initial jasperreport looks great. But the export is what I'm having problems with.

 @Command

}


This worked nicely when using MVC, so I figured it would work using MVVM. However, all I get are empty PDF documents.

Suggestions?

Edit: At sjoshi's suggestion, I tried populating with the jasperPrint object, my resulting code is as follows: follows:

 JRDataSource ds = datasource;
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
JasperPrint jasperPrint = JasperFillManager.fillReport(Executions.getCurrent().getDesktop().getWebApp().getRealPath("/") + "statementTemplate.jasper", parameters, ds);
byte[] ba = JasperExportManager.exportReportToPdf(jasperPrint);
System.out.println("bytestream: " + ba.length);
} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}


This gave me the same issue of blank documents, but on further inspection I'm seeing that the byte array is ending up nearly empty, even though the datasource has 33 records. The byte array should have a length of about 59k. So I think the source of the problem is somewhere with the application of the datasource to the report, a step missing or something.

Is there something that goes on in the background between a jasperreport object being populated with data and it being displayed in a <jasperreport> tag? I'm not doing that with this MVVM setup, but my guess would be that something is missing there.

Support Options
• Email Support
• Training
• Consulting
• Outsourcing