Category: | Bug report |
Priority: | High |
Status: | New |
Project: | Severity: | Major |
Resolution: | Open |
|
Component: | Reproducibility: | Always |
Assigned to: |
I have a template which loads parameters at runtime from a repository datafile in JSON format.
In the JSON datafile, there is an array containing elements (For randering tables) and within each element, there are key-value pairs and a "details" array (For randering rows in each table).
The JSON looks like this:
[
{
"var_1": "Item #1",
"var_2": true,
"var_3": 1,
"details": [
{
"detail_var_1": "Details #1.1",
"detail_var_2": false
},
{
"detail_var_1": "Details #1.2",
"detail_var_2": false
}
]
},
{
"var_1": "Item #2",
"var_2": true,
"var_3": 1,
"details": [
{
"detail_var_1": "Details #2.1",
"detail_var_2": false
},
{
"detail_var_1": "Details #2.2",
"detail_var_2": false
}
]
}
]
The "details" array is loaded as subDataset and the key-value pairs are iternated and mapped to pre-defined fields for display. For example,
<subDataset name="Dataset" whenResourceMissingType="Empty" uuid="1f2dfe8e-6398-4302-a872-d35d3d9fbc3c">
<queryString language="json">
<![CDATA[details]]>
</queryString>
<field name="detail_var_1" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="detail_var_1"/>
<fieldDescription><![CDATA[detail_var_1]]></fieldDescription>
</field>
<field name="detail_var_2" class="java.lang.Boolean">
<property name="net.sf.jasperreports.json.field.expression" value="detail_var_2"/>
<fieldDescription><![CDATA[detail_var_2]]></fieldDescription>
</field>
</subDataset>
<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" whenNoDataType="AllSectionsNoDetail">
<datasetRun subDataset="Dataset" uuid="21e1d8df-8018-4a87-aece-874005209344">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("details")]]></dataSourceExpression>
</datasetRun>
<jr:columnGroup width="551" uuid="2784ed19-df76-494f-93f5-67b0e1cc8d32">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [11]"/>
<jr:columnFooter height="5" rowSpan="1">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField>
<reportElement x="0" y="0" width="551" height="5" uuid="9e9b80d9-89e1-44a0-a1e1-8b5d23414c27">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<box>
<topPen lineWidth="1.0"/>
</box>
<textElement>
<font isBold="true"/>
</textElement>
</textField>
</jr:columnFooter>
<jr:columnGroup width="551" uuid="c8314c9b-7f9a-4b7e-995e-2524b67dd797">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [11]"/>
<jr:columnGroup width="551" uuid="ee196359-cfb6-4a8c-9bb4-464168966aa2">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [11]"/>
<jr:columnHeader height="20" rowSpan="1">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField>
<reportElement x="0" y="0" width="551" height="20" uuid="0d532719-3dcb-4778-8c28-b610b593e482"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Table Header"]]></textFieldExpression>
</textField>
</jr:columnHeader>
<jr:column width="30" uuid="e15cfdc8-1b33-4879-b489-bd539e459352">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
<jr:columnHeader height="55" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField>
<reportElement x="0" y="0" width="30" height="55" uuid="183af5e7-a3c0-44da-a3d9-783bb12af80d"/>
<box padding="5">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.5" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["S/N"]]></textFieldExpression>
</textField>
</jr:columnHeader>
<jr:detailCell height="30">
<textField textAdjust="StretchHeight" isBlankWhenNull="true">
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="46" height="30" isPrintWhenDetailOverflows="true" uuid="208741be-74f0-4693-86d5-a2912330a9be"/>
<box padding="5">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Top">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{detail_var_1}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="f2492306-277a-4c07-bad8-2180b2c6b80b">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
<jr:columnHeader height="55" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<textField>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="70" height="55" uuid="c7d19393-49b3-4ad2-916d-3d176a1fa009"/>
<box padding="5">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Active"]]></textFieldExpression>
</textField>
</jr:columnHeader>
<jr:detailCell height="30">
<textField textAdjust="StretchHeight" isBlankWhenNull="true">
<reportElement style="Style2" positionType="Float" stretchType="ElementGroupHeight" x="0" y="0" width="70" height="30" isPrintWhenDetailOverflows="true" uuid="440b908c-6ab6-49a1-b360-e29d937d8b71"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[!$F{detail_var_2}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
</jr:columnGroup>
</jr:columnGroup>
</jr:table>
It works as expected from v7.5.0 to v8.1.1. The tables can be rendered depending on the size of in elements in JSON and for each table, the no. of rows are also rendered depending on the no. of elements in "details" array and the values are also filled in the table rows.
However, since v8.2.0, only the tables and table rows can be rendered but not the values (i.e. Only the table layouts, without values).
It seems there are issues in v8.2.0.
Grateful if the issues can be addressed and fixed in future release. Thanks.
2 Comments:
Please provide a whole (and self contained) report *.jrxml file so that we can reproduce the issue.
Regards,
Lucian