Detect empty jrprint ?

Hello,

I'd like to know how can I detect an empty report before loading it with the JRLoader.loadObject() method.

Because when I want to export a report (always the same) with several differents dates given in parameter, I've got white pages in the exported pdf (for each date which has no data in the database source).

Is it possible ? Thank for help.
seboss's picture
31
Joined: Aug 8 2006 - 7:36pm
Last seen: 16 years 7 months ago

4 Answers:

You want to decide whether a report is empty before you load it? I don't think that's possible.

If you want to decide whether a report is empty, you first need to set whenNoDataType="NoPages" for the report design and then (when you have the filled report) check jasperPrint.getPages().isEmpty().

Regards,
Lucian
lucianc's picture
72627
Joined: Jul 17 2006 - 1:10am
Last seen: 46 min 25 sec ago
I explain again, I use this code :

Code:
<br />
ArrayList<Object> jpl = new ArrayList<Object>();<br />
String fileGen = JasperFillManager.fillReportToFile(reportPath,parameters, bdd.getConnection());<br />
jpl.add(JRLoader.loadObject(fileGen));</td></tr></tbody></table><br />
<br />
I just want to make something like this :<br />
<br />
<table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><br />
ArrayList<Object> jpl = new ArrayList<Object>();<br />
String fileGen = JasperFillManager.fillReportToFile(reportPath,parameters, bdd.getConnection());<br />
if (!report.isEmpty())	jpl.add(JRLoader.loadObject(fileGen));</td></tr></tbody></table><br />
<br />
But I don't understand how to do with jasperPrint.getPages().isEmpty().<br>Post edited by: seboss, at: 2006/08/31 07:18
seboss's picture
31
Joined: Aug 8 2006 - 7:36pm
Last seen: 16 years 7 months ago
Code:
JasperPrint jasperPrint =<br />
(JasperPrint)JRLoader.loadObject(fileGen);<br />
if(!jasperPrint.getPages().isEmpty()) {<br />
 jpl.add(jasperPrint);<br />
} <br />
</td></tr></tbody></table>
Alexander Merz's picture
Joined: Jul 31 2006 - 11:16pm
Last seen: 16 years 8 months ago
Ok, I didn't see that JRLoader.loadObject() return a jasperprint...

Thanks a lot
seboss's picture
31
Joined: Aug 8 2006 - 7:36pm
Last seen: 16 years 7 months ago
Feedback