sunflowerrahul Posted December 3, 2013 Share Posted December 3, 2013 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 Link to comment Share on other sites More sharing options...
netti royala Posted December 5, 2013 Share Posted December 5, 2013 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 Link to comment Share on other sites More sharing options...
sunflowerrahul Posted December 28, 2013 Author Share Posted December 28, 2013 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now