0

I am adding a report to the content part of jasper books. This report reads 3 data fields from data base, and after running has 3 pages as there should be. Running the book though creates 3 times more pages than the report itself, which mean it gets instantiated for each data field. If I move my report to the cover part it will be instantiated just once and it looks right. But I think this is not the right place for putting that and it should be placed int the content part. The source code can be seen at Duplicate data in jasper.

The structure of my report book looks like below: enter image description here

How can I make the content part to be repeated just once?

Community
  • 1
  • 1
Iman
  • 769
  • 1
  • 13
  • 51

1 Answers1

2

The content section in report books is data driven, corresponding to the detail band in reports. The section repeats for each record from the book data source/query.

Therefore if you only want the content section to occur once in the book, you should use a data source/query that produces a single record. That could be an "empty" data source with one record (as created by the "One Empty Record" in Jaspersoft Studio), or a query that returns a single record (if you don't need any actual DB values in the book you can have a dummy query such as select 1).

dada67
  • 4,723
  • 17
  • 19
  • After dragging the report to content part I chose use an empty expression. After running the book I get an Category series name is null exception – Iman Jun 17 '16 at 13:43
  • 1
    Do you mean empty data source? My suggestion was to use an empty data source (or dummy query) for the book itself, not for the report used as book content. – dada67 Jun 17 '16 at 13:51
  • my bad, sorry. Now I have created an empty data source, and assigned jasper book to that. but now the content will not be shown at all. I see only cover and back cover parts – Iman Jun 17 '16 at 13:56
  • should I add something in connection expression or data source expression for that report at book? – Iman Jun 17 '16 at 14:03
  • You should somehow get one row as a result. As @dada67 has written, for example by a `SELECT 1`. This one row will lead to the generation of only one batch of sections. If you need to get some results in the root Work Book, make sure only one row is returned if feasible. – tobi6 Jun 17 '16 at 14:38