IAmYourFaja
IAmYourFaja

Reputation: 56904

Jasper Report Bands When No Data Source

My understanding is that if you don't supply a JRDataSource to the JasperFillManager, then the resultant JasperReport will not contain any detail bands.

For reasons outside the context of this question, I want to place a few components (bar chart, and a table) on a small/simple JasperReport, and I want the data to come from a HashMap that I'll pass in. Thus, I don't need a JRDataSource implementation, which also means I won't get any detail bands.

So my question is: then what band(s) should I be adding my components to? The detail band is where I would normally add components to, but if I don't get a detail band, where does these orphaned components go?

Edit: Tangential to this question would be the obvious: how would I then calculate the size (height) that this band would need to be?

Upvotes: 4

Views: 4338

Answers (2)

Giorgos Dimtsas
Giorgos Dimtsas

Reputation: 12609

You can pass a JREmptyDatasource to the JasperFillManager. You can even specify how many virtual records you want, i.e. how many detail bands will be displayed, using the JREmptyDataSource#JREmptyDataSource(int count) constructor.

Upvotes: 4

mdahlman
mdahlman

Reputation: 9390

Put them in the Title or Summary band.

In effect your report will have no data. But since you're passing in a Map as a parameter with "data", then you are happy with this data-less report. Be sure the report is set to show "All Sections, No Detail" when there is no data.

With a chart you just set the chart height and band height however you want. A table component will expand... but that's not a problem. It can expand the Title or Summary band as needed.

Upvotes: 2

Related Questions