passing values from java to subDataset of jasper report

0

Hi, I have a jasper report  that looks like as the below one:

<?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="example" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fa59020a-3185-421b-bde5-da571f9082ca">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="tableDataset" uuid="b5e1b805-4e23-48ae-837e-19835f2038cb">
<queryString language="MYSQL">
<![CDATA[SELECT ID,CITY FROM participant]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="CITY" class="java.lang.String"/>
<field name="STREET" class="java.lang.String"/>
<group name="CITY">
<groupExpression><![CDATA[$F{CITY}]]></groupExpression>
</group>
</subDataset>
<title>
<band height="58" splitType="Stretch">
<componentElement>
<reportElement key="table" style="table" x="0" y="0" width="299" height="46" uuid="48f85d24-beb7-4d1a-b823-4ea54b387a3e"/>
<datasetRun subDataset="tableDataset" uuid="d86e885a-a776-4dfa-8c24-346b8d74792f">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="90" uuid="d88dc5bf-d0af-4f45-a25c-db3d829f6e30">
<jr:groupHeader groupName="CITY">
<jr:cell height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="96487c3f-a5df-4a1f-86fb-d7c89a46447b"/>
<textFieldExpression><![CDATA[$F{CITY}]]></textFieldExpression>
</textField>
</jr:cell>
</jr:groupHeader>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="19d3236e-eadc-4890-9797-a587332211ef"/>
<text><![CDATA[Id]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="44a6fd0c-ac80-4e35-8677-08c79d3f46d8"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="e1b974c8-1ccb-4a20-ba61-731e62a251db">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="35dbcb35-a726-484e-b812-b70ec1df2abb"/>
<text><![CDATA[Street]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="d0e0abc9-4a74-4880-9e92-616896633890"/>
<textFieldExpression><![CDATA[$F{STREET}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</title>
</jasperReport>
Now Please tell me, that how can i pass the values from the java class to the subDataset tag and also the corresponding code that has to be added to the datasetRun tag.
faariz1992's picture
Joined: Dec 6 2014 - 5:32am
Last seen: 4 years 3 months ago

1 Answer:

0

Not sure exactly what you're asking, but add some clarification if possible. Otherwise, parameters are your friend. Define it (whatever IT is) as a parameter, pass it to your subdataset).

darth_fader's picture
Joined: Mar 7 2010 - 9:45pm
Last seen: 2 weeks 1 day ago
Feedback
randomness