Jump to content
Changes to the Jaspersoft community edition download ×

malkav.82l03

Members
  • Posts

    4
  • Joined

  • Last visited

malkav.82l03's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. Ok now I solved the layout problem too. Recap: First: pass the JsonDataSource to the filler directly without calling subDataSet method: JsonDataSource jds = new JsonDataSource(inputStream);JasperPrint report = JasperFillManager.fillReport(compiled,parameters, jds); [/code] Second: use these expression in the main report to define the subreport <subreport><reportElement x="0" y="0" width="555" height="100" uuid="3f4dece2-5563-4df9-9cda-15623e0f6127"/><dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("json.Peoples")]]></dataSourceExpression><subreportExpression><![CDATA[$P{SUBREPORT_OBJ}]]></subreportExpression></subreport>[/code]The parameter SUBREPORT_OBJ is there because I'm compiling the subereport's .jrxml in my java application so I pass the subreport to the main report as an object. Normally we define a path for the .jasper of the subreport but in my project I do all the work at runtime. Third: in the sub report jrxml file put the fields into the detail band and get rid of the <querystring> tag (I'm not sure of this, but because I'm doing the selection into the main report, I deleted that tag and It works.... ) These steps worked for me. I hope will be useful for other people.
  2. I solved the problem of the exception using the default parameter REPORT_DATA_SOURCE and passing the json data source into the filling method instead of the JREmptyDataSource, but now I have another problem. It prints only the first Name and there isn't an iteration on the element. Is it a layout problem? How to make a iterable subreport?
  3. Hello, I have a similar problem. Did you solved it? Can you post the jrxml of the main report and of the subreport? I'm getting exception like this: Exception in thread "main" net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: ((net.sf.jasperreports.engine.data.JsonDataSource)$P{REP_DS}).subDataSource("json.Peoples") at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:264) at net.sf.jasperreport`enter code here`s.engine.fill.JRCalculator.evaluate(JRCalculator.java:610) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:578) at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1015) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:454) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:345) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:454) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2029) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:755) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:262) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:122) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:551) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:411) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:122) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:667) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:983) at report.services.JSONTEST.generateReport(JSONTEST.java:105) at report.services.JSONTEST.main(JSONTEST.java:33) Caused by: net.sf.jasperreports.engine.JRException: No node available. Iterate or rewind the data source. at net.sf.jasperreports.engine.data.JsonDataSource.subDataSource(JsonDataSource.java:455) at master_1437312305950_565620.evaluate(master_1437312305950_565620:173) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:251) ... 18 more[/code]
  4. Hello guys, i have this json String { "json":{ "Peoples":[ { "name":"Joseph" }, { "name":"Ilda" } ] }}[/code]And this is my Java code: InputStream is = new ByteArrayInputStream(json.getBytes("UTF-8"));JsonDataSource js = new JsonDataSource(is).subDataSource("json.Peoples");[/code]on the second instruction i get always this exception: Exception in thread "main" net.sf.jasperreports.engine.JRException: No node available. Iterate or rewind the data source.at net.sf.jasperreports.engine.data.JsonDataSource.subDataSource(JsonDataSource.java:455)[/code]What is wrong? The same problem if i don't do that instruction and pass the JsonDataSources without calling subDataSource method these are my jrxml files: MAIN: <?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="master" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="357402bb-9c06-432f-9a61-8df8fc82c81d"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="SUBREPORT_DS" class="java.lang.Object"/> <parameter name="REP_DS" class="java.lang.Object"/> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="61" splitType="Stretch"/> </columnHeader> <detail> <band height="125" splitType="Stretch"> <subreport> <reportElement x="0" y="0" width="555" height="100" uuid="3f4dece2-5563-4df9-9cda-15623e0f6127"/> <dataSourceExpression> <![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REP_DS}).subDataSource("json.Peoples")]]> </dataSourceExpression> <subreportExpression> <![CDATA[$P{SUBREPORT_DS}]]> </subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>[/code]SUBREPORT: <?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="slave" pageWidth="555" pageHeight="100" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="d001d4a5-f459-4ae5-b2ea-fda2f051cbab"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <queryString language="json"> <![CDATA[]]> </queryString> <field name="Nome" class="java.lang.String"/> <title> <band height="79" splitType="Stretch"> <textField> <reportElement x="34" y="22" width="100" height="20" uuid="4238a2f9-d7a1-4be0-8804-9c7c0ca30da6"/> <textFieldExpression> <![CDATA[$F{Nome}]]> </textFieldExpression> </textField> </band> </title></jasperReport>[/code]
×
×
  • Create New...