mariel.o.feitosa Posted April 29, 2019 Share Posted April 29, 2019 Pessoal boa tarde,Estou tentando fazer um relatorio master-detail com subreport e json e retorna este erro:The method SubDataSource(String) is undefined for the type JsonDataSource.Segue os arquivos Master e detalhe:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b --><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="70a346e7-ef00-450f-8d08-7102b79008eb"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="daMDModulo"/> <queryString language="json"> <![CDATA[cad_mod]]> </queryString> <field name="fabricante__descricao" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="fabricante__descricao"/> <fieldDescription><![CDATA[fabricante__descricao]]></fieldDescription> </field> <field name="id" class="java.lang.Integer"> <property name="net.sf.jasperreports.json.field.expression" value="id"/> <fieldDescription><![CDATA[id]]></fieldDescription> </field> <field name="cad_mod_inv" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="cad_mod_inv"/> <fieldDescription><![CDATA[cad_mod_inv]]></fieldDescription> </field> <field name="codigo" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="codigo"/> <fieldDescription><![CDATA[codigo]]></fieldDescription> </field> <field name="descricao" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="descricao"/> <fieldDescription><![CDATA[descricao]]></fieldDescription> </field> <field name="modelo" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="modelo"/> <fieldDescription><![CDATA[modelo]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="33" splitType="Stretch"> <staticText> <reportElement x="-2" y="0" width="100" height="30" uuid="d3e9accd-aa48-45df-a937-f12336c21f19"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d27a2e66-770e-41ae-a7b4-1eb64e5405c1"/> </reportElement> <text><![CDATA[codigo]]></text> </staticText> <staticText> <reportElement x="101" y="0" width="100" height="30" uuid="b4c95f96-f5c2-4f22-a3b8-728826dfe9f6"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="c8c57ac0-a4be-4ac3-9d3e-85291e9f8d14"/> </reportElement> <text><![CDATA[descricao]]></text> </staticText> <staticText> <reportElement x="312" y="0" width="128" height="30" uuid="b16201bb-f636-4902-ad25-2edbe1795f07"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="0d37c1ad-3cba-45da-a400-fd93c79d4f33"/> </reportElement> <text><![CDATA[fabricante__descricao]]></text> </staticText> <staticText> <reportElement x="457" y="0" width="100" height="30" uuid="58b0e421-e317-4ce8-a34c-6effdc066519"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d22dbe0a-c436-45d4-83f1-6e22262b2275"/> </reportElement> <text><![CDATA[id]]></text> </staticText> </band> </columnHeader> <detail> <band height="74" splitType="Stretch"> <textField> <reportElement x="-2" y="4" width="100" height="30" uuid="1beef8ce-6234-4cb3-a303-2d4cd934884e"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d27a2e66-770e-41ae-a7b4-1eb64e5405c1"/> </reportElement> <textFieldExpression><![CDATA[$F{codigo}]]></textFieldExpression> </textField> <textField> <reportElement x="101" y="4" width="209" height="30" uuid="d6941ddb-1333-4213-b480-0e3671ad0c8f"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="c8c57ac0-a4be-4ac3-9d3e-85291e9f8d14"/> </reportElement> <textFieldExpression><![CDATA[$F{descricao}]]></textFieldExpression> </textField> <textField> <reportElement x="314" y="4" width="126" height="30" uuid="471d55b2-8cea-43c8-914c-1ddba1e3de1c"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="0d37c1ad-3cba-45da-a400-fd93c79d4f33"/> </reportElement> <textFieldExpression><![CDATA[$F{fabricante__descricao}]]></textFieldExpression> </textField> <textField> <reportElement x="457" y="3" width="100" height="30" uuid="42f5c65d-06fa-48e0-85af-744c5449af2d"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d22dbe0a-c436-45d4-83f1-6e22262b2275"/> </reportElement> <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> </textField> <subreport> <reportElement x="80" y="40" width="470" height="26" uuid="95d6d71a-1494-4bbd-8775-dae6dcd3d355"/> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).SubDataSource("cad_mod.cad_mod_inv")]]></dataSourceExpression> <subreportExpression><![CDATA["Detalhe.jasper"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band splitType="Stretch"/> </columnFooter> <pageFooter> <band splitType="Stretch"/> </pageFooter> <summary> <band splitType="Stretch"/> </summary></jasperReport> Detalhe :<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b --><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="Detalhe" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6441673b-ed1e-4207-ae7e-a5c4500f4fdb"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="daMDModulo"/> <queryString language="json"> <![CDATA[cad_mod.cad_mod_inv]]> </queryString> <field name="qtde_min" class="java.lang.Integer"> <property name="net.sf.jasperreports.json.field.expression" value="qtde_min"/> <fieldDescription><![CDATA[qtde_min]]></fieldDescription> </field> <field name="modulo_id" class="java.lang.Integer"> <property name="net.sf.jasperreports.json.field.expression" value="modulo_id"/> <fieldDescription><![CDATA[modulo_id]]></fieldDescription> </field> <field name="qtde_max" class="java.lang.Integer"> <property name="net.sf.jasperreports.json.field.expression" value="qtde_max"/> <fieldDescription><![CDATA[qtde_max]]></fieldDescription> </field> <field name="potencia" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="potencia"/> <fieldDescription><![CDATA[potencia]]></fieldDescription> </field> <field name="invesor_id" class="java.lang.Integer"> <property name="net.sf.jasperreports.json.field.expression" value="invesor_id"/> <fieldDescription><![CDATA[invesor_id]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band splitType="Stretch"/> </title> <pageHeader> <band splitType="Stretch"/> </pageHeader> <columnHeader> <band height="39" splitType="Stretch"> <staticText> <reportElement x="0" y="0" width="100" height="30" uuid="0b505a6f-df24-48d8-9e22-428cbc27d68d"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="48d5c1ef-75cf-4f62-99d0-1f55c1f77b02"/> </reportElement> <text><![CDATA[modulo_id]]></text> </staticText> </band> </columnHeader> <detail> <band height="38" splitType="Stretch"> <textField> <reportElement x="0" y="3" width="100" height="30" uuid="a05e66fd-75da-4531-a798-d4f007bc4701"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="48d5c1ef-75cf-4f62-99d0-1f55c1f77b02"/> </reportElement> <textFieldExpression><![CDATA[$F{modulo_id}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band splitType="Stretch"/> </columnFooter> <pageFooter> <band splitType="Stretch"/> </pageFooter> <summary> <band splitType="Stretch"/> </summary></jasperReport> Json:{ "cad_mod":[ { "fabricante__descricao":null, "id":13, "cad_mod_inv":[ { "qtde_min":16, "modulo_id":13, "qtde_max":16, "potencia":null, "invesor_id":51 }, { "qtde_min":5, "modulo_id":13, "qtde_max":5, "potencia":null, "invesor_id":23 }, { "qtde_min":6, "modulo_id":13, "qtde_max":6, "potencia":null, "invesor_id":3 }, { "qtde_min":5, "modulo_id":13, "qtde_max":5, "potencia":null, "invesor_id":4 }, { "qtde_min":10, "modulo_id":13, "qtde_max":10, "potencia":null, "invesor_id":39 }, { "qtde_min":12, "modulo_id":13, "qtde_max":12, "potencia":null, "invesor_id":21 }, { "qtde_min":5, "modulo_id":13, "qtde_max":5, "potencia":null, "invesor_id":5 }, { "qtde_min":4, "modulo_id":13, "qtde_max":4, "potencia":null, "invesor_id":27 }, { "qtde_min":5, "modulo_id":13, "qtde_max":5, "potencia":null, "invesor_id":2 }, { "qtde_min":10, "modulo_id":13, "qtde_max":10, "potencia":null, "invesor_id":11 }, { "qtde_min":11, "modulo_id":13, "qtde_max":11, "potencia":null, "invesor_id":41 }, { "qtde_min":7, "modulo_id":13, "qtde_max":7, "potencia":null, "invesor_id":46 }, { "qtde_min":4, "modulo_id":13, "qtde_max":4, "potencia":null, "invesor_id":33 }, { "qtde_min":5, "modulo_id":13, "qtde_max":5, "potencia":null, "invesor_id":24 }, { "qtde_min":6, "modulo_id":13, "qtde_max":6, "potencia":null, "invesor_id":28 }, { "qtde_min":8, "modulo_id":13, "qtde_max":8, "potencia":null, "invesor_id":17 }, { "qtde_min":4, "modulo_id":13, "qtde_max":4, "potencia":null, "invesor_id":22 }, { "qtde_min":25, "modulo_id":13, "qtde_max":25, "potencia":null, "invesor_id":38 }, { "qtde_min":12, "modulo_id":13, "qtde_max":12, "potencia":null, "invesor_id":13 }, { "qtde_min":10, "modulo_id":13, "qtde_max":10, "potencia":null, "invesor_id":14 }, { "qtde_min":5, "modulo_id":13, "qtde_max":5, "potencia":null, "invesor_id":12 }, { "qtde_min":11, "modulo_id":13, "qtde_max":11, "potencia":null, "invesor_id":15 }, { "qtde_min":16, "modulo_id":13, "qtde_max":16, "potencia":null, "invesor_id":52 }, { "qtde_min":12, "modulo_id":13, "qtde_max":12, "potencia":null, "invesor_id":26 } ], "codigo":"", "descricao":"Mu00d3DULO TALESUN 320W", "modelo":"TP672P - 320W" } ]} Link to comment Share on other sites More sharing options...
narcism Posted April 30, 2019 Share Posted April 30, 2019 You are calling a method that does not exist: SubDataSource(String). However, the subDataSource(String) method exists(method names start with lowercase letters in Java). Use that instead. Link to comment Share on other sites More sharing options...
mariel.o.feitosa Posted April 30, 2019 Author Share Posted April 30, 2019 Obrigado por Responder amigo,Eu vi isso e ja corrigi, mas agora os dados do filho não aparecem, eu teria que fazer mais alguma coisa?Você teria um exemplode como fazer isso, pois sou moito novo em Jasper.Abraço, Mariel Link to comment Share on other sites More sharing options...
Solution narcism Posted April 30, 2019 Solution Share Posted April 30, 2019 Your subreport's dataSource expression needs to look like this:<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("cad_mod_inv")]]></dataSourceExpression>[/code]because you are already iterating items under the cad_mod key(you specified that in the the main report's query string). Link to comment Share on other sites More sharing options...
mariel.o.feitosa Posted April 30, 2019 Author Share Posted April 30, 2019 Que coisa mais linda, deu certinho.Salvou meu dia, muito, muito obrigado NarcismAbraço. 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