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

Jasper sub report not displaying data.


coolbreeze

Recommended Posts

Hi All, 

I am trying to create a sub-report within a main report in jasper. I am not connecting to any data base but passing in a map of parameters to the report. I have defined the parameters for the sub report in the main report and am passing them through the sub-report properties. Sub report runs fine when ran individually but when i try to execute it via the main report none of the sub report data is populated. I have an inkling that it has something to do with the Data Source Expression (have chosen Connection Type to "Use a datasource expression" but i have not been successful in either solving it or finding some help online.  Also, attached is the generateReport method that i call to generate a pdf report

I am attaching my jrxml files and any help would be appreciated. 

dlr_report1.jrxml - main report

dlr_report1_subreport1.jrxml - sub report

 

Code:



Post Edited by coolbreeze at 07/07/2012 01:19



Post Edited by coolbreeze at 07/07/2012 01:29



Post Edited by coolbreeze at 07/07/2012 01:36
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

 

When you are using reports without any data query at all there is a setting called "When No Data", you access this in the properties of the main report items in the report inspector.

 

I set your parent reports to "When No Data = All Sections, No Detail", and your subreport to "When No Data = No Data". Moved your subreport definition to the column header band. Moved your fields in the sub report to the "No Data" section.

Also changed your connection type to "Don't Pass Data", but don't be confused this has nothing to do with why your setup wasn't working.

Anyway take a look at the updated templates, should help you understand. Paramters don't need any additional special mapping or configuration, if you define them in the subreport parameter map then they will be passed into the sub report.

Hope this helps,

Clark

 

 

Link to comment
Share on other sites

 Hi Clark,

Thanks for taking time out and responding to my question. I did try the changes you suggested and am still not able to get data in the sub-report section of the main report. I am not sure what i am doing wrong, from whatever i am reading it sounds pretty simple but still it is not working for me. Before it was being split into two pages but now it is all in one page but the detail section of the report is still blank. 

Thanks again for the recommendations.

 

**editing 

Sorry so i changed the SUBREPORT_DIR from giving relative path to "./" and the values seem to be populated but are populated with nulls. I only have one map (containing parameters for both main and sub report). Here are the steps i took to create these parameters.

Populate a map with key1/val1, key2/val2, key3/val3, key4/val4. 

Add the parameters key1, key2, key3 & key4 in the main report parameter list.

Add the parameters key1, key2, key3 & key4 in the sub report parameter list.

In the fields in the "No Data" section, i reference $P{key1} with $P{key1} in the Text Field Expression. 

Do you think i am doing something wrong based on these steps? Also, could the same variable/parameter names be causing ambiguity? Attaching the new main report xml for your reference.

Thanks!

 

ps : this is the map i am passing :

{vehicleListedTitle=Times Vehicles Listed, vehicleListedNewValue=123, accountRepName=Tony Smith, dlrListedNewValue=123, dlrListedTitle=Times

Dealer Listed, address1=123 26th Street, address2=this City, CA 90812, accountRepEmail=tsmith@email.com, dealerShipName=this Honda}

Code:



Post Edited by coolbreeze at 07/09/2012 06:13



Post Edited by coolbreeze at 07/09/2012 06:22
Link to comment
Share on other sites

 Hi Clark/Others,

I was able to solve the final glitch. It was just a clean up left out of doing all the changes trying to make the report to work. In my supreport attribute in the main report, i was passing 5 parameters and the naming was off and hence the value was never getting passed down to the sub report. 

For my main report parameters i am using CamelCasing and for sub report parameters i am using underscores to differentiate the difference in parameter type and destination. 

So the gist from all this effort as  i gather is not to use the detail section of the subreport if we are not going to be using sql connection to pass data, since we changed the band from detail to column header? Clark, if you get a moment could you verify the same? Apart from that creating parameters in main and sub, mapping in properties and using them in sub report should work fine.

 

Thanks a lot Clark for all your help, you sure guided me in the right direction. Now off to pass a bean as a data source to further complicate matters:)..

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...