How do I display a jasperreport without a datasource. The report is suppose to receive parameters from the java application and display them.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With