mresh Posted March 21, 2016 Share Posted March 21, 2016 I am using jasper studio 6.1.1. I am trying to pass a field as a parmeter to my subreport and then use that parameter in a sql query to retrieve additional data to ouput in the subreport. the following is my main report code eventDetails.jrxml. <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1 --><!-- 2016-03-21T17:12:26 --><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="eventDetails" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fd461282-d8ef-4693-b392-8099d8766ec1"> <property name="net.sf.jasperreports.print.create.bookmarks" value="true"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="ProjectEvents_DATAADAPTER.xml"/> <parameter name="SRP_STATUSID" class="java.lang.Integer" isForPrompting="false"/> <queryString> <![CDATA[]]> </queryString> <field name="eventDate" class="java.sql.Date"> <fieldDescription><![CDATA[eventDate]]></fieldDescription> </field> <field name="eventType" class="java.lang.String"> <fieldDescription><![CDATA[eventType]]></fieldDescription> </field> <field name="title" class="java.lang.String"> <fieldDescription><![CDATA[title]]></fieldDescription> </field> <field name="eventId" class="java.lang.Integer"> <fieldDescription><![CDATA[eventId]]></fieldDescription> </field> <field name="eventProjectId" class="java.lang.Integer"> <fieldDescription><![CDATA[eventProjectId]]></fieldDescription> </field> <field name="statusId" class="java.lang.Integer"> <fieldDescription><![CDATA[statusId]]></fieldDescription> </field> <field name="state" class="java.lang.Integer"> <fieldDescription><![CDATA[state]]></fieldDescription> </field> <field name="descriptionId" class="java.lang.Integer"> <fieldDescription><![CDATA[descriptionId]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band splitType="Stretch"/> </title> <pageHeader> <band height="43" splitType="Stretch"> <staticText> <reportElement x="227" y="13" width="100" height="17" uuid="f76bb01e-b410-464b-b1e9-fe86cef089a3"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <text><![CDATA[Event Details]]></text> </staticText> </band> </pageHeader> <columnHeader> <band height="91" splitType="Stretch"> <staticText> <reportElement x="-10" y="0" width="100" height="30" uuid="6e8f583e-6f25-459a-bdb0-bda5abacb1c0"/> <text><![CDATA[eventProjectId]]></text> </staticText> <staticText> <reportElement x="-10" y="61" width="50" height="30" uuid="8121ba38-fa4e-40bf-b4ef-59b0e2c4a9c7"/> <text><![CDATA[eventType]]></text> </staticText> <staticText> <reportElement x="50" y="60" width="60" height="30" uuid="7e6ebe78-83e5-454d-bff4-ab822ba0dac6"/> <text><![CDATA[eventDate]]></text> </staticText> <staticText> <reportElement x="120" y="60" width="100" height="30" uuid="4e5d5b03-fa70-470f-a9de-618a35b62f5f"/> <text><![CDATA[title]]></text> </staticText> <textField> <reportElement x="100" y="6" width="100" height="24" uuid="644e28b1-ae00-418c-a0af-ec1eb66eb675"/> <textFieldExpression><![CDATA[$F{eventProjectId}]]></textFieldExpression> </textField> <staticText> <reportElement x="230" y="60" width="100" height="30" uuid="b31a04ff-1ed5-47c9-b43d-add75d17a91c"/> <text><![CDATA[statusId]]></text> </staticText> <staticText> <reportElement x="340" y="60" width="100" height="30" uuid="e529e96a-2026-4c97-a881-09fcc1177370"/> <text><![CDATA[state]]></text> </staticText> </band> </columnHeader> <detail> <band height="493" splitType="Stretch"> <textField> <reportElement x="-10" y="10" width="50" height="30" uuid="4e3895a1-e748-4427-b97e-e804eb7ecfd8"/> <textFieldExpression><![CDATA[$F{eventType}]]></textFieldExpression> </textField> <textField> <reportElement x="50" y="10" width="70" height="30" uuid="45ab8789-3c11-400e-8138-063f71448213"/> <textFieldExpression><![CDATA[$F{eventDate}]]></textFieldExpression> </textField> <textField> <reportElement x="127" y="10" width="100" height="30" uuid="496d1577-a0c9-487d-a28d-42e031aeb61f"/> <textFieldExpression><![CDATA[$F{title}]]></textFieldExpression> </textField> <textField> <reportElement x="240" y="10" width="100" height="30" uuid="18ddee79-a371-4a97-b0f7-bfa1bd5b018c"/> <textFieldExpression><![CDATA[$F{statusId}]]></textFieldExpression> </textField> <textField> <reportElement x="350" y="10" width="100" height="30" uuid="897850be-8029-4e18-9180-55669a664811"/> <textFieldExpression><![CDATA[$F{state}]]></textFieldExpression> </textField> <subreport> <reportElement positionType="Float" x="-10" y="80" width="550" height="110" uuid="edc4d949-7837-4b66-967d-f5587d491a4a"/> <subreportParameter name="SRP_STATUSID"> <subreportParameterExpression><![CDATA[$F{statusId}]]></subreportParameterExpression> </subreportParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["eventDetails_Sub1.jasper"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band splitType="Stretch"/> </summary></jasperReport> [/code] and here is my eventDetails_Sub1.jrxml <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1 --><!-- 2016-03-21T17:14:46 --><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="eventDetails_Sub1" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d6db356c-97ea-4adb-805e-51998e2088b2"> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="CubeValue_SQL_DATAADAPTER.xml"/> <parameter name="SRP_STATUSID" class="java.lang.Integer" isForPrompting="false"> <parameterDescription><![CDATA[]]></parameterDescription> </parameter> <queryString> <![CDATA[sELECT *FROM ConfigValuesWHERE configvalues.`configValueID` =$P{SRP_STATUSID}]]> </queryString> <field name="configValueID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="configType" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="projectID" class="java.lang.Integer"> <fieldDescription><![CDATA[projectid=zero is the defaults for all projects (global system values)]]></fieldDescription> </field> <field name="name" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="displaySeq" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="workflowSeq" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="allowUse" class="java.lang.Boolean"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band splitType="Stretch"/> </title> <pageHeader> <band splitType="Stretch"/> </pageHeader> <columnHeader> <band splitType="Stretch"/> </columnHeader> <detail> <band height="37" splitType="Stretch"> <textField> <reportElement x="220" y="3" width="100" height="30" uuid="5024bf79-ee18-416d-aa68-921099d619d0"/> <textFieldExpression><![CDATA["Testing"]]></textFieldExpression> </textField> <textField> <reportElement x="-10" y="0" width="150" height="30" uuid="2086b756-eed5-436c-b3ec-a5f2f46e5da0"/> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band splitType="Stretch"/> </columnFooter> <pageFooter> <band splitType="Stretch"/> </pageFooter> <summary> <band splitType="Stretch"/> </summary></jasperReport> [/code] Link to comment Share on other sites More sharing options...
mresh Posted March 21, 2016 Author Share Posted March 21, 2016 I pasted it in using your xml code block and the little pop up occurred to repaste and this is what it did. You need to fix your code block Link to comment Share on other sites More sharing options...
kkriplani Posted March 22, 2016 Share Posted March 22, 2016 Hi,The image above displays the parameter linking between the main report and subreport. The left colum (Name) is the name of the parameter of the subreport that has to be linked with fields/parameters of the main report. The first row gives an explaination while the second row is an example.Hope this helps,KKriplani. Link to comment Share on other sites More sharing options...
irfan.khazi123 Posted March 22, 2016 Share Posted March 22, 2016 Ireport Designer.Click on sub report. in the properties section got to parameters. and add the parameters which you want communicate through main report to subreport.Hope this helps. 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