Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasperreport without data source

How do I display a jasperreport without a datasource. The report is suppose to receive parameters from the java application and display them.

like image 658
spongyboss Avatar asked Jul 28 '14 13:07

spongyboss


People also ask

When no data Jasper?

Whenever there is NO data for your selected input controls to your report in jasper you can show NO data message either in the form of text or a No data image. For this you just need to enable a property for the Report. * Add "No Data" band to your report.

What is datasource in Jasper report?

Datasources are structured data container. While generating the report, JasperReports engine obtains data from the datasources. Data can be obtained from the databases, XML files, arrays of objects, and collection of objects.


1 Answers

The way I would do it is to still put all of your text fields, etc. into the detail band, then use a new JREmptyDataSource(1) as your datasource. I.e:

filledReport = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource(1));

Passing the value 1 to the constructor will create a single virtual record in the datasource, so the detail band will be printed only once. I prefer this method as it means the report template is more similar to a normal report template. The alternative is to have a completely empty datasource and then put all of your content into a different band (e.g. column header).

like image 80
GenericJon Avatar answered Oct 20 '22 19:10

GenericJon