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

jack.musajo

Members
  • Posts

    1
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Security Advisories

Downloads

Everything posted by jack.musajo

  1. Hi :) I'm struggling to find the right way to pass data to a subreport throug JAVA. Could someone help me? This is the snippet of my code and report. I tried to pass a parameter in the Jasper.FIllReport function, but it doesn't work at all.. Java code: URL url = new URL(repofileurl); URLConnection connection = url.openConnection(); InputStream reportFile = connection.getInputStream(); JasperReport jasperReport = JasperCompileManager.compileReport(reportFile); if (jrSet.getSubReportFileName() != null) { for (String filename : jrSet.getSubReportFileName()){ String subrepofileurl = REPO_TEMPLATE_URL+filename; URL suburl = new URL(subrepofileurl); URLConnection subconn = suburl.openConnection(); InputStream subtemp = subconn.getInputStream(); JasperReport jasperSubReport = JasperCompileManager.compileReport(subtemp); Collection<Object> testSubData = new ArrayList<>(); testSubData.add(new jasperTest()); JRBeanCollectionDataSource data = new JRBeanCollectionDataSource(testSubData); jrSet.getParameters().put("yourSubList", data); jrSet.getParameters().put("subreportParameter", jasperSubReport); } } JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jrSet.getParameters(),jrSet.getDataSource());[/code] Report (subreport part): <subreport> <reportElement x="160" y="4" width="392" height="83" uuid="25651434-2f73-4650-8102-20ad1d7b5e69"/> <subreportParameter name="yourSubList"> <subreportParameterExpression> <![CDATA[$P{yourSubList}]]> </subreportParameterExpression> </subreportParameter> <subreportParameter name="subreportParameter"> <subreportParameterExpression> <![CDATA[$P{subreportParameter}]]> </subreportParameterExpression> </subreportParameter> <subreportExpression> <![CDATA[$P{subreportParameter}]]> </subreportExpression>[/code]SubReport (filed to fill, but I don't know how to link the parameters): <textField> <reportElement x="10" y="6" width="100" height="30" uuid="2ca814dc-d485-41ab-9216-d5b5fbb2082b"/> <textFieldExpression><![CDATA[$P{Parameter1}]]></textFieldExpression> </textField> <textField> <reportElement x="160" y="10" width="100" height="30" uuid="0d13edc1-03b1-4e99-b654-8c463dc07a04"/> <textFieldExpression><![CDATA[$F{partenza}]]></textFieldExpression> </textField>[/code]I will be really grateful if someone could help me (or pointing in the right direction! I googled for weeks...)
×
×
  • Create New...