PDA

View Full Version : Report without Items?



Anonymous
07-05-2002, 04:55 AM
Hi,

I don't know whether we are trying to use JFreeReport for something it isn't designed for but:

We want to output what is in effect a document deriving data from a datasource where each page is unique without the concept of repeating "items" e.g a surveyors report.

We have tried representing each page as a group with no items defined.

We can produce a one page report fine but because we haven't defined items when we specify a second group even with pagebreak set to true it is just output over the first.

We have tried specifying an empty items tag but this has no effect.

We would appreciate your comments, suggestions.

regards Graham

Anonymous
07-05-2002, 07:00 AM
Hi,

have a closer look at the 2nd Demo, I think this report there does the same you want to do.

>We have tried representing each page as a group with no items
>defined.

This is good, and now define a group field list, which identifies the report page (create some sort of primary key). When creating such reports, I prefer using the surveyors ID. If you don't have a primary key, you can alternativly list all column names in the group field list, or you create a row-number column.

Have more fun,
said Thomas

Anonymous
07-05-2002, 07:42 AM
Hi,

Thanks for the reply but not sure this will work for us.

Doesn't this still mean that as a surveyor id changes it will output another page with different data but effectively the same layout.

Our requirement is to output one report for a single Id where the content of each page is totally different. e.g Name address on page 1 Inspection details page 2.

The definition for each page is different and we do not have many rows but effectively one big row where we want to print different elements of it on each page.

The closest example we can find is report 3. If this had a second page with a totally different layout but for the same Bookstore that is what we are trying to acheive.

regards Graham

Anonymous
07-07-2002, 03:55 PM
Hi,

OK, second try :)

Now this will be a tweak, so don't be scared. Every group header and group footer can do an page break. If you need only one more page, you can define the group-footer to contain the page. This should do the job.

It gets a little bit more complex on more than one page:
You will have to introduce a new field for every page you want to add. Then create a group for every additional field, and put your contents in the group header for that group:

An example for 2 more pages would look like this

The data:
Row1 = id // the surveyor id
Row2 = dummyField1 // a empty field to trigger the group printing
Row3 = dummyField2 // a empty field to trigger the group printing

The report definitions:
<groups>
<group name="report_page1">
<fields>
<field>id</field>
</fields>
<groupheader ... > .. page 1 ... </groupheader>
</group>
<group name="report_page2">
<fields>
<field>id</field>
<field>dummyField1</field>
</fields>
<groupheader ... > .. page 2 ... </groupheader>
</group>
<group name="report_page3">
<fields>
<field>id</field>
<field>dummyField1</field>
<field>dummyField2</field>
</fields>
<groupheader ... > .. page 3 ... </groupheader>
</group>
</groups>

Why does this work?
JFreeReport descends into all groups and keeps processing the items until it encounters a group change (at least one field in the group has changed). Then JFR leaves the groups until it reaches a non changing group (or the default group containing no fields).

So the print calls are as follows for the given example.

* ReportHeader
do
{
* GroupHeader ("report_page1")
* GroupHeader ("report_page2")
* GroupHeader ("report_page3")
* Items (*empty*)
> advance into the next row
> check for group change (is always as surveyor's ID is unique)
* GroupFooter ("Report_page3") // empty in the current example
* GroupFooter ("Report_page2") // empty in the current example
* GroupFooter ("Report_page1") // empty in the current example
}
while there are more rows in the datasource

* ReportFooter

I hope this solution fits better. If not, just tell it and we try to find a better solution.

Have more fun,
said Thomas

Anonymous
07-08-2002, 04:31 AM
Hi

Thanks This is exactly what we want to do and your solution does the trick.

Tell you what, I wish all Java Forums were like this one! Keep up the good work.