pokornyjan Posted February 20, 2019 Share Posted February 20, 2019 Hi,I have "report book" - main query (Select id (Int) from cr)and I woud like pass "id" to the Content report - query (Select name from alg where $X{IN, alg.CR_ID, id}).How configure report?Thanks for any help. Link to comment Share on other sites More sharing options...
pokornyjan Posted February 20, 2019 Author Share Posted February 20, 2019 When- the main query select only one value - set java.lang.Integer in the Content report parameter- set EQUAL in the Content report Queryreport is OK.When - the main query select more values - set java.util.Collection in the Content report parameter- set IN in the Content report QueryCaused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Collection Link to comment Share on other sites More sharing options...
Alex42 Posted February 21, 2019 Share Posted February 21, 2019 $X{IN, alg.CR_ID, id}) is used for multiselect parameters(collections). This will generate a SQL query where alg.CR_ID in (1,2,3......). This syntax expects a parameter of type collection and you are passing it a single value parameter(an integer). For single select values use alg.CR_ID=$P{id} in your query Link to comment Share on other sites More sharing options...
pokornyjan Posted March 14, 2019 Author Share Posted March 14, 2019 Hi Ale42,thank you for your answer. How configure (how passing id from main report to subreport?)?Main Report:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 7.2.1.final using JasperReports Library version 6.6.0 --><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="Test_parameter_id" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6d480b82-0505-4eed-adb6-b09c4618ab87"> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="SDM SQL"/> <queryString language="SQL"> <![CDATA[select id, ref_numfrom call_reqwhereid in (441673, 441674)]]> </queryString> <field name="id" class="java.lang.Integer"> <property name="com.jaspersoft.studio.field.label" value="id"/> </field> <field name="ref_num" class="java.lang.String"> <property name="com.jaspersoft.studio.field.label" value="ref_num"/> </field> <variable name="Variable_1" class="java.util.ArrayList" calculation="System"> <variableExpression><![CDATA[$F{id}]]></variableExpression> <initialValueExpression><![CDATA[new ArrayList()]]></initialValueExpression> </variable> <background> <band splitType="Stretch"/> </background> <summary> <band height="31"> <subreport> <reportElement x="0" y="5" width="528" height="25" uuid="aa870034-2312-4e13-b997-6e7216c55246"/> <subreportParameter name="id"> <subreportParameterExpression><![CDATA[$V{Variable_1}]]></subreportParameterExpression> </subreportParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["Blank_A4.jasper"]]></subreportExpression> </subreport> </band> </summary></jasperReport> Subreport:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 7.2.1.final using JasperReports Library version 6.6.0 --><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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a3dc58dc-90e6-4e2e-9457-d0434143dd60"> <parameter name="id" class="java.util.ArrayList"/> <queryString language="SQL"> <![CDATA[select id, ref_numfrom call_reqwhere$X{IN, id, id}]]> </queryString> <field name="id" class="java.lang.Integer"> <property name="com.jaspersoft.studio.field.label" value="id"/> </field> <field name="ref_num" class="java.lang.String"> <property name="com.jaspersoft.studio.field.label" value="ref_num"/> </field> <background> <band splitType="Stretch"/> </background> <pageHeader> <band height="50"> <textField> <reportElement x="142" y="16" width="100" height="30" uuid="9f8dceef-077c-4048-8de6-4e3330b039a8"/> <textFieldExpression><![CDATA[$P{id}]]></textFieldExpression> </textField> </band> </pageHeader> <detail> <band height="75" splitType="Stretch"> <textField> <reportElement x="20" y="40" width="100" height="30" uuid="4532c2b0-a210-4b72-89ea-69b33f5587bf"/> <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> </textField> <staticText> <reportElement x="20" y="10" width="100" height="30" uuid="a461cf14-cd5f-4cea-bac6-d1e15cb06df0"/> <text><![CDATA[id]]></text> </staticText> <textField> <reportElement x="120" y="40" width="100" height="30" uuid="6939f996-37b8-4741-9299-021d03a28aa4"/> <textFieldExpression><![CDATA[$F{ref_num}]]></textFieldExpression> </textField> <staticText> <reportElement x="120" y="10" width="100" height="30" uuid="ce3e2ec3-c11b-4c3a-937b-d3ae6bdc06f6"/> <text><![CDATA[ref_num]]></text> </staticText> </band> </detail></jasperReport> Link to comment Share on other sites More sharing options...
pokornyjan Posted March 19, 2019 Author Share Posted March 19, 2019 Similar problem is with ReportBook. How to passing values to report "Detail" (in "Content")? Report "Detail" has Table ("Basic Components" ).When I create table as fields, passing is OK.Single value is OK. 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