Jump to content
We've recently updated our Privacy Statement, available here ×

e-sarge

Members
  • Posts

    10
  • Joined

  • Last visited

e-sarge's Achievements

Rookie

Rookie (2/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. Thanks. I got it working (JRXML files attached below). By the way, very important for me resolving this was to ensure I had the same version of the Jasper Reports JAR file in Tomcat that I was using in my designer (iReports). Mine was a different version, and it failed silently, only symptom was blank detail rows in the sub-report (but sub-report page and column headers worked).
  2. I found the cause of the problem. In Tomcat, I had an older version of the Jasper Reports JAR. When I updated it to match the version used in iReports, the problem was resolved.
  3. 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.
  4. I had the same problem and just resolved it a few minutes ago. Mine was caused by an older version of the Jasper Reports JAR file in Tomcat (3.1.4) than I was using in iReports (3.7.1). When I deployed the newer JAR file to Tomcat, the problem was resolved.
  5. 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. Subreport definition is in the code window below and full JRXML files are attached. As an alternative to debugging my provided JRXML files, 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. displaying a 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. Thanks in advance for any assistance. Code:<field name="name" class="java.lang.String"/><field name="phoneNums" class="java.util.Collection"/>...<subreport> <reportElement x="100" y="0" width="200" height="60"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{phoneNums})]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA["reports/NamesAndNumbers_subreport1.jasper"]]></subreportExpression></subreport>
  6. Ugh. 5 years later and I am still having the same problems as the original poster, and still no answer is posted. charmadi posted a solution that only works when the content of the sub-report is unrelated to the main report data source, such as the content of a reference table. However, the main use of a sub-report should be for child data of the main report. For example, if printing a contact list, the main report would list persons (one detail row per person), and the sub-report would be used to print phone numbers (zero to many rows depending on how many phone numbers each person has). There is no way that the phone numbers data source can be set as suggested by charmadi, since the content of the data source needs to be sourced from the collection of phone numbers in the Person object in the main data source. Does anyone have an example to post here to answer my question and to close off this 5 year old unsolved thread? Thanks for any help.
  7. Another old thread that is incomplete, so I'll try to complete it. The answer was almost given above, but a few details were not quite correct, which might explain why the original poster did not recognize the solution. First, your main collection class should look similar to this: Class EmpDetail { String empCode; String empName; List ProjectDetails empDetails; } Notice the list/collection in your main class which will contain the source of data for the sub-report. Then, in the main report where you define your subreport, set the Data Source Expression property to the following: new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{empDetails}) The reference to field empDetails was key to understanding the solution and was not presented before.
  8. 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.
  9. I know this is old, but it is left unanswered. For future reference, the JRBeanCollectionDataSource needs to be constructed from a collection of objects of the same type. This is why you don't know how to access items from the collection. I think in your case your getShows() method should return new JRBeanCollectionDataSource(this.getShowSearchResults()). If your subreport also needs information from another source (e.g. from the master report data source) then you need to pass that to the sub-report as a parameter and not in the collection. Stated another way, (except for special scenarios like filtering and grouping) the JRBeanCollectionDataSource should contain the same number of items as the number of detail rows in the sub-report.
  10. 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.
×
×
  • Create New...