Jump to content

Subreport with JRBeanCollectionDataSource is Blank


e-sarge

Recommended Posts

I want to create a simple report with an equally simple subreport. The working example is for a contact list (just persons and phone numbers).

Person class has a String name and a Collection of phone numbers (for the one-to-many relationship).

PhoneNumber class has an int ID, a String type (work, home, cell, etc.), a String phoneNumber, and a Person (for the one-to-many relationship).

The main report works fine, listing all the names in my contacts list. However, the sub-report contains no data, only column header static text if the collection is not empty. My test data has 3 contacts. One contact has 3 phone numbers, the second has one phone number, and the third has no phone numbers.

It seems evident to me that the sub-report collection is working (since the column headers only print for persons with at least one phone number), but why is the phone number data not printing??? There must be some nuance about the JRBeanCollectionDataSource that is being constructed, but I can't find any working JRXML files for this scenario.

JRXML files are attached.

Thanks in advance for any assistance.


Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Or, perhaps someone can provide an example of a working subreport which uses a JRDataSource (specifically a JRBeanCollectionDataSource created from a collection in the main report's data source) and no parameters? To date I have not been able to find any examples posted with this configuration. The lack of examples in this configuration seems odd to me because I think what I am trying to do is the "normal" scenario for sub-reports (i.e. display main data source sub-collection data using a sub-report).

FYI, I am rendering this report in PDF format only, in case that makes any difference.

Link to comment
Share on other sites

Status Update [Resolved]:

I coded up a data factory method with similar test data (contact one with 3 phone numbers, contact two with 1 phone number, and contact three with no phone numbers). All contacts display with the correct number of phone number details in the sub-report. So it works in iReports Preview mode but the same JRXML/Jasper files still do not work deployed on Tomcat and using "live" Hibernate objects under Tomcat.

I saw someone else post on another forum with similar symptoms where it works in iReport but not under Tomcat, but the post was unanswered.

I then found another post somewhere else with slightly different symptoms but they suggested checking the version number of the Jasper Reports JAR file in Tomcat. This is when I found I had used 3.7.1 in iReports but was using 3.1.4 in Tomcat. I updated the Jasper Reports JAR in Tomcat and the problem was resolved.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...