MiditecReportDev Posted July 8, 2016 Share Posted July 8, 2016 I have a very serious problem when having my main report with it's dataset, inside of the main report is a table with it's own dataset which has a subreport inside one of it's cells.This subreport needs to get some field values given inside it's own parameters. However when I try to give the fields to the subreport I only see fields and parameters or variables from the main report dataset, not from the table dataset. I can select those and the expression is totally valid but the report won't compile as the subreport could not find the values (which to me is correct behaviour - so why offer them to me in the first place?). I can manually put the correct expressions there and the report will compile then but will not fill correctly as the subreport somehow will still not get the right values.So I can either use those value Jasper Studio offers me to use and get a non-compiling report or use the correct values and get the report to compile but have a piece of garbage then.What exactly is the problem there? oO Link to comment Share on other sites More sharing options...
Solution lucianc Posted July 11, 2016 Solution Share Posted July 11, 2016 Jaspersoft Studio proposing main dataset fields/variables is a bug, consider filing it in the trackers.But a proper expression using the table dataset seems to work fine to me. Do you have a self contained example to reproduce the problem that you found?Thank you,Lucian Link to comment Share on other sites More sharing options...
MiditecReportDev Posted July 12, 2016 Author Share Posted July 12, 2016 As I can't give you our company reports I just made a sample out of two reports. Main with table and sub (inside the table).Report compiles without problems when I fill in the field $F{SHIPNAME} from hand but will however not fill as the data seems not to be given into the subreport. Code of Main Report:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0 --><!-- 2016-07-12T07:15:14 --><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="Main" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1f893ec5-9a1c-4728-863a-d9eacb152c2c"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <subDataset name="TableDataset" uuid="cc9ba582-862e-4283-8f00-ffc76a6a22dc"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <parameter name="OrderID" class="java.lang.Integer"/> <queryString> <![CDATA[sELECT * FROM ORDERS WHERE ORDERID = $P{OrderID}]]> </queryString> <field name="ORDERID" class="java.lang.Integer"/> <field name="CUSTOMERID" class="java.lang.String"/> <field name="EMPLOYEEID" class="java.lang.Integer"/> <field name="ORDERDATE" class="java.sql.Timestamp"/> <field name="REQUIREDDATE" class="java.sql.Timestamp"/> <field name="SHIPPEDDATE" class="java.sql.Timestamp"/> <field name="SHIPVIA" class="java.lang.Integer"/> <field name="FREIGHT" class="java.math.BigDecimal"/> <field name="SHIPNAME" class="java.lang.String"/> <field name="SHIPADDRESS" class="java.lang.String"/> <field name="SHIPCITY" class="java.lang.String"/> <field name="SHIPREGION" class="java.lang.String"/> <field name="SHIPPOSTALCODE" class="java.lang.String"/> <field name="SHIPCOUNTRY" class="java.lang.String"/> </subDataset> <queryString> <![CDATA[sELECT ORDERID FROM ORDERS]]> </queryString> <field name="ORDERID" class="java.lang.Integer"/> <background> <band splitType="Stretch"/> </background> <title> <band height="30" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <staticText> <reportElement x="0" y="0" width="555" height="30" uuid="4f63821b-5cae-4347-bcdd-7ca94a038a42"> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> </reportElement> <text><![CDATA[Example]]></text> </staticText> </band> </title> <detail> <band height="60" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <componentElement> <reportElement x="0" y="0" width="555" height="60" uuid="af4d62b4-20ad-4b81-8eb9-076102bc1ee7"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> </reportElement> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="TableDataset" uuid="ce1200f0-3fa7-4216-965f-8d5d839428a6"> <datasetParameter name="OrderID"> <datasetParameterExpression><![CDATA[$F{ORDERID}]]></datasetParameterExpression> </datasetParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:column width="40" uuid="50957880-859d-4a8e-9eeb-b7789566c9d7"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="40" height="30" uuid="2735cc27-1ec8-4a53-b02a-1e5693725d6c"/> <textFieldExpression><![CDATA[$F{ORDERID}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40" uuid="7c027851-f31c-4b54-a1cf-4104ef85b68c"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="40" height="30" uuid="56e4c2a7-1729-4ce1-97ad-c755363622d5"/> <textFieldExpression><![CDATA[$F{CUSTOMERID}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40" uuid="8a12ccee-1f40-498c-8bd6-3861aa55bfa0"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="40" height="30" uuid="6af83270-b4c0-4ed5-a249-efb9e0539dd9"/> <textFieldExpression><![CDATA[$F{EMPLOYEEID}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40" uuid="61327c4f-a715-4895-baa5-d09f58f7016c"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="40" height="30" uuid="0e7ad0c6-83b5-4912-bb3b-68346d8f2ba7"/> <textFieldExpression><![CDATA[$F{ORDERDATE}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40" uuid="be279976-27a2-4300-89b3-a03538dbc1f9"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="40" height="30" uuid="572e634f-22e3-4d2e-b734-058392be227b"/> <textFieldExpression><![CDATA[$F{REQUIREDDATE}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40" uuid="f3aac2c5-fecb-4603-866c-0f51763e1f52"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column6"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="40" height="30" uuid="91babcba-a663-4955-b93e-b058e40d262c"/> <textFieldExpression><![CDATA[$F{SHIPPEDDATE}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40" uuid="50cadf93-0123-4742-84cf-e6ea395d2491"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column7"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="40" height="30" uuid="afd84df1-0bc0-4995-852e-6c397e9c38d2"/> <textFieldExpression><![CDATA[$F{SHIPVIA}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40" uuid="2088bfac-a959-497f-8af0-bb174b259e06"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column8"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="40" height="30" uuid="d991722c-dfc8-484f-9eca-27ffc7dcc315"/> <textFieldExpression><![CDATA[$F{FREIGHT}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="235" uuid="32135f06-772c-4e1b-b599-a6ad7cde9859"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column9"/> <jr:columnHeader height="30" rowSpan="1"/> <jr:detailCell height="30"> <subreport> <reportElement x="0" y="0" width="235" height="30" uuid="299fba81-ffb0-4652-9d83-e68d7d5f2057"/> <subreportParameter name="ShipName"> <subreportParameterExpression><![CDATA[$F{SHIPNAME}]]></subreportParameterExpression> </subreportParameter> <subreportExpression><![CDATA["Sub.jasper"]]></subreportExpression> </subreport> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </detail></jasperReport>[/code]Code of Subreport:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0 --><!-- 2016-07-12T07:16:05 --><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="Sub" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4f184e02-e9d4-4808-8b7e-07858b8166a6"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <parameter name="ShipName" class="java.lang.String"/> <queryString> <![CDATA[sELECT * FROM ORDERS WHERE SHIPNAME = $P{ShipName}]]> </queryString> <field name="ORDERID" class="java.lang.Integer"/> <field name="CUSTOMERID" class="java.lang.String"/> <field name="EMPLOYEEID" class="java.lang.Integer"/> <field name="ORDERDATE" class="java.sql.Timestamp"/> <field name="REQUIREDDATE" class="java.sql.Timestamp"/> <field name="SHIPPEDDATE" class="java.sql.Timestamp"/> <field name="SHIPVIA" class="java.lang.Integer"/> <field name="FREIGHT" class="java.math.BigDecimal"/> <field name="SHIPNAME" class="java.lang.String"/> <field name="SHIPADDRESS" class="java.lang.String"/> <field name="SHIPCITY" class="java.lang.String"/> <field name="SHIPREGION" class="java.lang.String"/> <field name="SHIPPOSTALCODE" class="java.lang.String"/> <field name="SHIPCOUNTRY" class="java.lang.String"/> <background> <band splitType="Stretch"/> </background> <columnHeader> <band height="30" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <staticText> <reportElement x="0" y="0" width="100" height="30" uuid="7e5a2610-38e5-494a-aee7-e023f3aad9d5"/> <text><![CDATA[sHIPNAME]]></text> </staticText> <staticText> <reportElement x="200" y="0" width="100" height="30" uuid="2ec86bb2-b681-4ba8-b64b-1ddf52da5ffa"> <property name="com.jaspersoft.studio.unit.y" value="pixel"/> </reportElement> <text><![CDATA[sHIPADDRESS]]></text> </staticText> <staticText> <reportElement x="400" y="0" width="100" height="30" uuid="9144275e-0eea-44e4-b988-383b80492865"/> <text><![CDATA[sHIPCITY]]></text> </staticText> <staticText> <reportElement x="100" y="0" width="100" height="30" uuid="579a1967-c762-498a-a326-6e1469ead32a"/> <text><![CDATA[sHIPREGION]]></text> </staticText> <staticText> <reportElement x="300" y="0" width="100" height="30" uuid="5a40dbfa-0d9b-45e4-9df3-5f3817d2af7f"> <property name="com.jaspersoft.studio.unit.y" value="pixel"/> </reportElement> <text><![CDATA[sHIPCOUNTRY]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <textField> <reportElement x="0" y="0" width="100" height="30" uuid="bddebae8-f26c-40ea-86ef-b413690a442a"/> <textFieldExpression><![CDATA[$F{SHIPNAME}]]></textFieldExpression> </textField> <textField> <reportElement x="200" y="0" width="100" height="30" uuid="385cad10-9395-4453-8071-27e03ec3f1e6"/> <textFieldExpression><![CDATA[$F{SHIPADDRESS}]]></textFieldExpression> </textField> <textField> <reportElement x="400" y="0" width="100" height="30" uuid="e65a6ce9-0af2-4a69-a161-019e4275b5bb"/> <textFieldExpression><![CDATA[$F{SHIPCITY}]]></textFieldExpression> </textField> <textField> <reportElement x="100" y="0" width="100" height="30" uuid="d9a2b2d8-011f-47b3-aa2f-220d73cc7279"/> <textFieldExpression><![CDATA[$F{SHIPREGION}]]></textFieldExpression> </textField> <textField> <reportElement x="300" y="0" width="100" height="30" uuid="fe03c200-5c84-4be3-9ffa-92e0e746eaff"/> <textFieldExpression><![CDATA[$F{SHIPCOUNTRY}]]></textFieldExpression> </textField> </band> </detail></jasperReport>[/code] So currently there seems to be no way to have subreports inside tables at all o_O Greetings, Patrick Link to comment Share on other sites More sharing options...
lucianc Posted July 12, 2016 Share Posted July 12, 2016 What the subreport is missing is the connection on which to run its query.You can pass the connection from the master report by adding <connectionExpression>$P{REPORT_CONNECTION}</connectionExpression>[/code] in the subreport element. Link to comment Share on other sites More sharing options...
MiditecReportDev Posted July 12, 2016 Author Share Posted July 12, 2016 You're absolutely right that's what I forgot in that example. It works now and I can't (as I needed to find a workaround fast) say that it can not have been the same problem in the "real" report as well. Maybe, maybe not.Still the bug remains. Can you tell me how to properly report it as it really needs fixing? I need to show people how to use Jasper Reports soon and I have worked with it for 6 months now and have those problems. Can't imagine my poor phone when people are confronted with this when they just started using Jasper. Link to comment Share on other sites More sharing options...
lucianc Posted July 12, 2016 Share Posted July 12, 2016 Are you talking about the problem with Jaspersoft Studio not using the right dataset for subreport expressions? Log a bug at http://community.jaspersoft.com/bug-tracker so that the JSS team is aware about the problem. Link to comment Share on other sites More sharing options...
MiditecReportDev Posted July 12, 2016 Author Share Posted July 12, 2016 That's exactly what I wanted, thanks ;) 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