How to fill the subreport within the subreport?

0

Hi Guys,

I have scenario where MainReport has subreport1 and subreport1 has subreport2? Able to display the value till the subreport1 level but not able to print the subreport2 under the subreport1 :(

I am struggling from last 4 days. 

MainReport-->SubReport1--> SubReport2. 

I have to use XMLDataSource. Issue with subreport1-->subreport2 value coming null.

 

InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xmlString));
Document document = db.parse(is);
reportParams.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT,document);
reportParams.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "dd-MMM-yyyy");
reportParams.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##");
reportParams.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
reportParams.put(JRParameter.REPORT_LOCALE, Locale.US);
/*subReport1*/

 

JasperReport subReport1= (JasperReport) JRLoader
.loadObjectFromFile(request.getSession().getServletContext()
.getRealPath("/")
+ "Reports/subReport1.jasper");
 
reportParams.put("SUBREPORT1", subReport1);
 
/* subreport2*/ 
JasperReport subReport2 = (JasperReport) JRLoader
.loadObjectFromFile(request.getSession().getServletContext()
.getRealPath("/") + "Reports/subreport2.jasper");
reportParams.put("SUBREPORT2", tradeDetailsSubReport);
 
 
/*Main Report*/
 
JasperPrint jasperPrintReport = JasperFillManager.fillReport(request
.getSession().getServletContext().getRealPath("/")
+ "Reports/main.jasper", reportParams);
 
 
In the main.jasper
<parameter name="SUBREPORT1" class="net.sf.jasperreports.engine.JasperReport"/>
 
In the subreport1.jasper
<parameter name="SUBREPORT2" class="net.sf.jasperreports.engine.JasperReport"/>

Passing the same "XML_DATA_DOCUMENT" as parameter in the subQuery.

Report is generated using the JasperStudio with the dummy xmlDataSource by passing harcoding the name of the subreport file name.

Please let me know , am i doing wrong, seems in Java i have to do change.please suggest

 

 

 

sunflowerrahul's picture
Joined: Nov 5 2013 - 10:23pm
Last seen: 5 years 5 months ago

2 Answers:

0
are you passing any parameters to the sub reports.Then you should declare those Parameters in Main Report also.can you post .jrxml file ,include also sub reports.it is small mistake..if you post it will easily to recoganise the mistake
netti royala's picture
Joined: Oct 28 2013 - 11:43pm
Last seen: 4 years 6 months ago
0

Yeah, i have fixed the issue. I was not apssing the paramter from main report for subreport 2. So we need to pass the paramter from mainreport to subreport then subreport1 . Also in the java also in the main report only we need to set the parameter.

sunflowerrahul's picture
Joined: Nov 5 2013 - 10:23pm
Last seen: 5 years 5 months ago
Feedback