Remove line when blank when beside an image - jasper-reports

So I figured out how to have a textbox be removed and it's space collapse when it is null/blank.
But now I have an image on the other side of the page that is stopping this functionality.
I'm guessing since it is on the same line it won't collapse the space.
This is what it looks like:
... -------------------
Address 1 | |
Address 2 (if blank remove) | PICTURE |
Address 3 (if blank remove) | |
... -------------------
Is there a way to have the image not affect this? Can I put it in a frame or something? Or is there a property I am unaware of?
Hopefully someone has come across this before.

Since you have figured out "how to have a textbox be removed and it's space collapse when it is null/blank", I assume that you are aware of attributes like isBlankWhenNull="true" and isRemoveLineWhenBlank="true".
But now you have a picture in the same vertical space along with address fields. So you have to put them into two different vertical frames. Enclose the fields Address1, Address2, Address3 etc. into one frame and picture into other frame. Here is the sample JRXML code to test it. Save this code as report2.jrxml and run it. Play around the values of parm1...parm5 to get desired output.
<?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="report2" language="groovy" pageWidth="979" pageHeight="693" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="979" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="a6ccd207-3a74-42e6-8486-fc3b01795fb5">
<parameter name="par1" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par2" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par3" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par4" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par5" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<pageHeader>
<band height="174" splitType="Stretch">
<line>
<reportElement x="10" y="61" width="520" height="1" uuid="9e329029-596a-4741-80b2-4dd31e7f0a2a"/>
</line>
<line>
<reportElement x="10" y="157" width="520" height="1" uuid="eee16285-f6e5-4275-9911-b8ba0b330c08"/>
</line>
<frame>
<reportElement x="46" y="65" width="154" height="76" uuid="fac4c0b1-a3b2-431a-b766-1954512e5b12"/>
<textField isBlankWhenNull="true">
<reportElement x="42" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="949799db-d6be-404d-98c5-e6a69c0d917f"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par3} == null ? null : "P3: " + $P{par3}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="42" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="a1b3fa51-8c0e-496d-8759-2a51eb58bc33"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par1} == null ? null : "P1: " + $P{par1}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="42" y="40" width="52" height="20" isRemoveLineWhenBlank="true" uuid="3944fa92-8b0c-4965-81c2-036696bb1295"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par5} == null ? null : "P5: " + $P{par5}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement x="341" y="65" width="189" height="76" uuid="b074b915-2d61-4df8-95b1-12e3901b0604"/>
<textField isBlankWhenNull="true">
<reportElement x="62" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="8c371d13-9eb4-4cf6-b9b8-38052e0dc933"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par2} == null ? null : "P2: " + $P{par2}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="62" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="eee7c8ca-a46c-40f1-9701-36a388357108"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par4} == null ? null : "P4: " + $P{par4}]]></textFieldExpression>
</textField>
</frame>
</band>
</pageHeader>
</jasperReport>
OUTPUT:
When all params are non null
OUTPUT: When P3 is null

Related

Why does only my first subreport display?

I'm trying to display several tables in one Jasper Report and I use sub reports for this feature. But I'm stuck with displaying several sub reports. Actually, only one of them (the first) is displayed.
Here is my main report.jrxml:
<?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="multitable" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1c6dc1c9-67af-43d5-bf1e-9243557c8048">
<property name="net.sf.jasperreports.json.source" value="C:/jdd/projects/StackTrace/jasper/multitable.json"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["reports/hardware/"]]></defaultValueExpression></parameter>
<parameter name="title" class="java.lang.String"/>
<parameter name="period" class="java.lang.String"/>
<parameter name="DS1" class="net.sf.jasperreports.engine.data.JsonDataSource"/>
<parameter name="DS2" class="net.sf.jasperreports.engine.data.JsonDataSource"/>
<queryString language="json">
<![CDATA[]]>
</queryString>
<detail>
<band height="120" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="50" uuid="91249d6e-57f7-4b6d-8d2a-05059efa2a47"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="16"/>
</textElement>
<textFieldExpression><![CDATA[$P{title}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="652" y="0" width="100" height="50" uuid="67e1ca07-588a-4b2b-ae93-ecbdb544b01b"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="16"/>
</textElement>
<textFieldExpression><![CDATA[$P{period}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="50" width="555" height="20" uuid="48a7bbe4-b8ce-4a0d-a6e1-6ddd288e5602"/>
<dataSourceExpression><![CDATA[$P{DS1}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "printersSubreport.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<summary>
<band height="305" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="50" uuid="91249d6e-57f7-4b6d-8d2a-05059efa2a47"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="16"/>
</textElement>
<textFieldExpression><![CDATA[$P{title}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="50" width="555" height="32" uuid="780a1f25-065e-494a-ba1d-86a33b464343"/>
<dataSourceExpression><![CDATA[$P{DS2}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subjectSubreport.jasper"]]></subreportExpression>
</subreport>
</band>
</summary>
</jasperReport>
Here is subjectSubreport.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 -->
<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="multitable_summary" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="2a869c20-1e7d-4baa-92d7-c8d555f1f344">
<queryString language="json">
<![CDATA[]]>
</queryString>
<field name="subject" class="java.lang.String"/>
<field name="zipCode" class="java.lang.Integer"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="23">
<staticText>
<reportElement x="0" y="0" width="100" height="20" uuid="a9730039-8418-4e58-a2eb-0babe8d2a380"/>
<text><![CDATA[Subject]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="20">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="100" height="20" backcolor="#CCCCCC" uuid="a49b18ef-63c3-42bb-ae81-8d7d72ac9086"/>
<box leftPadding="0">
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Subject]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="100" y="0" width="100" height="20" backcolor="#CCCCCC" uuid="c1c70fed-d887-429f-a3b0-ed645517e41f"/>
<box leftPadding="0">
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[ZipCode]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="401436b3-d9a1-40bd-8a1d-dfa3f162f842"/>
<box leftPadding="0">
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{subject}]]></textFieldExpression>
</textField>
<textField pattern="###0">
<reportElement x="100" y="0" width="100" height="20" uuid="4447d3b0-6d3e-4795-8b5f-6a09d620448b"/>
<box leftPadding="0">
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zipCode}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
And here is printersSubreport.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 -->
<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="multitable_subreport" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="5f89d251-66b1-4658-9af5-c057de138fb6">
<field name="statusDesc" class="java.lang.String"/>
<field name="lastUpdateTime" class="java.lang.Integer"/>
<field name="criticalCount" class="java.lang.String"/>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="100" height="20" backcolor="#CCCCCC" uuid="bbb8857c-471c-4aca-a8fc-336d2748d7b9"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Description]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="100" y="0" width="100" height="20" backcolor="#CCCCCC" uuid="3fde89c9-d9a3-4972-8e3b-b2e619a51601"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[UpdateTime]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="200" y="0" width="100" height="20" backcolor="#CCCCCC" uuid="e82ece60-c92e-4d0b-8881-29d7d0d78e81"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Count]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="cdec861a-8b3b-413f-8b99-74d0e18ee19d"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{statusDesc}]]></textFieldExpression>
</textField>
<textField pattern="###0.##">
<reportElement x="100" y="0" width="100" height="20" uuid="9dfb9f78-74e5-4562-84fd-ebb87c3203ce"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{lastUpdateTime}]]></textFieldExpression>
</textField>
<textField pattern="ยค #,##0.00">
<reportElement x="200" y="0" width="100" height="20" uuid="923ff62d-ea1f-410e-94d3-fa7c574c001b"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{criticalCount}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
When I switch sub reports the first of them displays correctly, and the other one disappears. In JasperSoft Studio everything is fine, the problem starts when I export them to pdf/xls.
Actually, only one of them (the first) is displayed.. When I switch sub reports the first of them displays correctly, and the other one disappears
You are declaring:
<parameter name="DS1" class="net.sf.jasperreports.engine.data.JsonDataSource"/>
<parameter name="DS2" class="net.sf.jasperreports.engine.data.JsonDataSource"/>
The JRDatasource is consumable, which means that if you use it to fill one report it will be consumed hence for next report calling next() on same datasource will return false.
What you are experiencing is what happens if you pass same (same Object) datasource for DS1 and DS2, DS1 will be consumed filling first subreport and then since DS1 == DS2 DS2 will already be consumed when filling second subreport, second report will have no records (empty).
Solution
You need to make a clone DS1, create a new Object and pass that as DS2. The JsonDataSource is theoretically also a JRRewindableDataSource, so you could call moveFirst() before filling second subreport, but this is not very easy from the jrxml file so I don't suggest trying to use this method.

Jasperreport remove vertical space inside frames

I have a jasperreport and I am trying to reduce the vertical size of its two frames. As you can see in this screenshot
The 3 frames (the surrounding frame and the two internal frames) are larger than the contents.
I have been struggling to reduce their size to the size of the contents but without success. Any ideas what I can do? The par1 = null, par2=2, par3=3, par4=4.
My jasperreport:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 -->
<!-- 2015-12-23T17:08:07 -->
<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="report2" language="groovy" pageWidth="979" pageHeight="693" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="979" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="a6ccd207-3a74-42e6-8486-fc3b01795fb5">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="par1" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par2" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par3" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par4" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<title>
<band height="80" splitType="Stretch">
<line>
<reportElement x="10" y="6" width="520" height="1" uuid="ebfc40ae-a2ee-40fc-b585-4236e9fa3c63"/>
</line>
<line>
<reportElement x="10" y="72" width="520" height="1" uuid="7657216f-1366-4455-adb0-db58e2333b5c"/>
</line>
<frame>
<reportElement x="329" y="10" width="172" height="59" isRemoveLineWhenBlank="true" uuid="0fbab6b3-f5ea-4716-b954-9371b4640781">
<property name="ShowOutOfBoundContent" value="false"/>
</reportElement>
<box>
<topPen lineWidth="0.4"/>
<leftPen lineWidth="0.4"/>
<bottomPen lineWidth="0.4"/>
<rightPen lineWidth="0.4"/>
</box>
<frame>
<reportElement positionType="Float" x="13" y="3" width="60" height="54" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="8a663ee5-c983-40f9-b85e-11bc852f46cc">
<property name="ShowOutOfBoundContent" value="false"/>
</reportElement>
<box>
<topPen lineWidth="0.4"/>
<leftPen lineWidth="0.4"/>
<bottomPen lineWidth="0.4"/>
<rightPen lineWidth="0.4"/>
</box>
<textField isBlankWhenNull="true">
<reportElement x="1" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="84504631-a04d-4f75-bcb2-9e20741f29ad"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par3} == null ? null : "P3: " + $P{par3}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="1" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="52c7e555-7e36-4992-8e59-b533fea31533"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par1} == null ? null : "P1: " + $P{par1}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="73" y="3" width="70" height="54" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="3a53c02d-6559-4c64-8ca8-21254b50435e">
<property name="ShowOutOfBoundContent" value="false"/>
</reportElement>
<box>
<topPen lineWidth="0.4"/>
<leftPen lineWidth="0.4"/>
<bottomPen lineWidth="0.4"/>
<rightPen lineWidth="0.4"/>
</box>
<textField isBlankWhenNull="true">
<reportElement x="1" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="b0ca90f0-9364-4c4c-a8cf-1a54c60189a0"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par2} == null ? null : "P2: " + $P{par2}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="1" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="f8b11d9c-fa8c-4e58-805a-4a8305b1bec1"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par4} == null ? null : "P4: " + $P{par4}]]></textFieldExpression>
</textField>
</frame>
</frame>
</band>
</title>
</jasperReport>
Edit:
I tried to reduce the size of the frames and set their removeLineWhenBlank property to true, and now everything disappears if I set the values par1=par2=null, par3=3, par4=4. Why ? I only want to remove the lines that are blank, not all of them:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 -->
<!-- 2015-12-23T18:22:07 -->
<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="report2" language="groovy" pageWidth="979" pageHeight="693" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="979" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="a6ccd207-3a74-42e6-8486-fc3b01795fb5">
<parameter name="par1" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par2" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par3" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<parameter name="par4" class="java.lang.String">
<defaultValueExpression><![CDATA[null]]></defaultValueExpression>
</parameter>
<title>
<band height="141" splitType="Stretch">
<line>
<reportElement x="10" y="6" width="520" height="1" uuid="ebfc40ae-a2ee-40fc-b585-4236e9fa3c63"/>
</line>
<line>
<reportElement x="0" y="110" width="520" height="1" uuid="7657216f-1366-4455-adb0-db58e2333b5c"/>
</line>
<frame>
<reportElement x="329" y="10" width="172" height="43" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="0fbab6b3-f5ea-4716-b954-9371b4640781">
<property name="ShowOutOfBoundContent" value="false"/>
</reportElement>
<box>
<topPen lineWidth="0.4"/>
<leftPen lineWidth="0.4"/>
<bottomPen lineWidth="0.4"/>
<rightPen lineWidth="0.4"/>
</box>
<frame>
<reportElement positionType="Float" x="13" y="3" width="60" height="40" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="8a663ee5-c983-40f9-b85e-11bc852f46cc">
<property name="ShowOutOfBoundContent" value="false"/>
</reportElement>
<box>
<topPen lineWidth="0.4"/>
<leftPen lineWidth="0.4"/>
<bottomPen lineWidth="0.4"/>
<rightPen lineWidth="0.4"/>
</box>
<textField isBlankWhenNull="true">
<reportElement x="1" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="84504631-a04d-4f75-bcb2-9e20741f29ad"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par3} == null ? null : "P3: " + $P{par3}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="1" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="52c7e555-7e36-4992-8e59-b533fea31533"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par1} == null ? null : "P1: " + $P{par1}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="73" y="3" width="70" height="40" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="3a53c02d-6559-4c64-8ca8-21254b50435e">
<property name="ShowOutOfBoundContent" value="false"/>
</reportElement>
<box>
<topPen lineWidth="0.4"/>
<leftPen lineWidth="0.4"/>
<bottomPen lineWidth="0.4"/>
<rightPen lineWidth="0.4"/>
</box>
<textField isBlankWhenNull="true">
<reportElement x="1" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="b0ca90f0-9364-4c4c-a8cf-1a54c60189a0"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par2} == null ? null : "P2: " + $P{par2}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="1" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="f8b11d9c-fa8c-4e58-805a-4a8305b1bec1"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$P{par4} == null ? null : "P4: " + $P{par4}]]></textFieldExpression>
</textField>
</frame>
</frame>
</band>
</title>
</jasperReport>
what is the format that you are generating your reports. Lets assume you are generating reports in HTML format and the following trick will do the job.
<property name ="net.sf.jasperreports.export.html.using.images.to.align" value="false"/>
Hope that helps .

How to display one group per page using Jasper Reports?

I'm using iReport to create a Jasper Report template, and I need to display one group per page:
Group 1: (Page One)
-Field1 Field2 Field3
Group 2: (Page Two)
-Field1 Field2 Field3
And so on.
I tried setting the Maximize Band Height property to true in the "Group Footer" band using iReport, but some empty pages are added when I try to review.
You can use isStartNewPage attribute of group.
You can add Group Header band and
1) set "Start on a new page" attribute as true
2) set band height as 0 (if you don't need it).
The working sample
The jrxml file:
<?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="group_break" language="groovy" pageWidth="400" pageHeight="400" columnWidth="360" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2bcb6f3d-2169-44f6-9e8a-db54ea21b5e0">
<queryString>
<![CDATA[SELECT DOCUMENTID, PRODUCTID, PRICE FROM POSITIONS ORDER BY DOCUMENTID]]>
</queryString>
<field name="DOCUMENTID" class="java.lang.Integer"/>
<field name="PRODUCTID" class="java.lang.Integer"/>
<field name="PRICE" class="java.math.BigDecimal"/>
<group name="docId" isStartNewPage="true">
<groupExpression><![CDATA[$F{DOCUMENTID}]]></groupExpression>
<groupHeader>
<band/>
</groupHeader>
</group>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="111" height="20" uuid="596f5fb4-7e6d-4e7e-88bf-b9c37d0fb1a1"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Position]]></text>
</staticText>
<staticText>
<reportElement x="111" y="0" width="111" height="20" uuid="4884f663-00cf-4b5f-9cc1-05d698b8154a"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement x="222" y="0" width="111" height="20" uuid="26c8d18f-2281-405c-a41b-bddcbcdebdbb"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Price]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="111" height="20" uuid="fb6369eb-4b92-41dd-b5b8-94a9210bf315"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$F{DOCUMENTID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="111" y="0" width="111" height="20" uuid="9fcbb785-06fa-4f7a-bc6d-301cc8db4388"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$F{PRODUCTID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="222" y="0" width="111" height="20" uuid="0d18c9fe-5a70-4890-b94d-f26d88bc97da"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$F{PRICE}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="50">
<textField>
<reportElement x="0" y="20" width="80" height="20" uuid="47486fe9-e21f-4913-a9c4-cef0d3e2df39"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="80" y="20" width="40" height="20" uuid="0f7df66b-bbe6-4373-962e-519584c44541"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
</jasperReport>
The result
The output result generated in iReport via preview mode

How to avoid using a lots of ternary operators for translation of value to text

I am using JasperReports to create some reports of a Django web application.
Let's say that I have a model that has an id and a value. This value is a Django choice so I end up in my database with only the keys and not the values (the values are in my code). To make it more clear for people that don't use Django, I end up with something like that in my database:
id value
1 'GD'
2 'VG'
3 'VG'
4 'VG'
5 'GD'
6 'AV'
7 'GD'
8 'AV'
I want to display Good instead of 'GD', Average instead of 'AV' and Very Good instead of VG in my report. I know that this can be done with two equally not desirable to me options:
Create a new table in my database that has key - value and join that in the JR query. I really hate this because I'd need to create around 10 such tables.
Use the ternary operator to display the correct value:
field.equals("GD")?"Good":(field.equals("AV")?"Average":(field.equals("VG")?"Very good":"-"))
I also hate this because it would be very complicated if I had, for instance, 10 key-value pairs.
My ideal solution would be to define a dictionary (HashMap) variable in my report that would contain all the key value pairs and then just do a DICTIONARY.get(field) to represent the field value. Can this be done ? Can you possibly propose another, better solution?
Please don't tell me to alter my database design, I know that some people won't like but it perfect for my needs.
You can solve this issue with help of Java. For example, the Guava library can help us in solving this task.
Using report's parameter
We can add the parameter of java.util.Map type and use it for extracting the value by the key (it can be the value field from your sample)
The sample:
<?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="using_map" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e566b23d-ca97-472e-9cc3-8073573f4537">
<import value="com.google.common.collect.*"/>
<import value="com.google.common.base.*"/>
<parameter name="values" class="java.util.Map" isForPrompting="false">
<defaultValueExpression><![CDATA[new ImmutableMap.Builder<String, String>().put("GD", "Good").put("AV", "Average").build()]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<field name="id" class="java.lang.String"/>
<field name="value" class="java.lang.String"/>
<columnHeader>
<band height="20">
<staticText>
<reportElement uuid="f23f6abc-cd9b-4415-a591-cb7a51ad0392" x="0" y="0" width="100" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement uuid="f23f6abc-cd9b-4415-a591-cb7a51ad0392" x="100" y="0" width="100" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value]]></text>
</staticText>
<staticText>
<reportElement uuid="f23f6abc-cd9b-4415-a591-cb7a51ad0392" x="200" y="0" width="100" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value from Map]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="8eb8bbef-430b-4ad1-b592-000fe7ccce9f" x="0" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8eb8bbef-430b-4ad1-b592-000fe7ccce9f" x="100" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8eb8bbef-430b-4ad1-b592-000fe7ccce9f" x="200" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$P{values}.get($F{value})]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
In this sample we use ImmutableMap.Builder class for creating and filling the Map.
The result will be (via iReport preview):
As you can see that the third columns contains null value for values that are not in Map.
Note: Don't forget to add Guava library to classpath.
Using scriptlet
You can do the same with help of Scriptlets.
You can write the simple Java class with static method, for example for getting value from the Map.
Using internationalization mechanism
May be the simplest way is to use report's internationalization support.
You can attach the properties file with values to your report.
The sample of jrxml:
<?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="localization" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="marks" uuid="a5d74b61-8d62-41ac-b874-76d6f40da79e">
<queryString>
<![CDATA[]]>
</queryString>
<field name="id" class="java.lang.String"/>
<field name="value" class="java.lang.String"/>
<columnHeader>
<band height="20">
<staticText>
<reportElement uuid="f23f6abc-cd9b-4415-a591-cb7a51ad0392" x="0" y="0" width="100" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement uuid="f23f6abc-cd9b-4415-a591-cb7a51ad0392" x="100" y="0" width="100" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value]]></text>
</staticText>
<staticText>
<reportElement uuid="f23f6abc-cd9b-4415-a591-cb7a51ad0392" x="200" y="0" width="114" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value from Properties]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="8eb8bbef-430b-4ad1-b592-000fe7ccce9f" x="0" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8eb8bbef-430b-4ad1-b592-000fe7ccce9f" x="100" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8eb8bbef-430b-4ad1-b592-000fe7ccce9f" x="200" y="0" width="114" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[str($F{value})]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
The marks.properties file:
GD=Good
AV=Average
VG=Very Good
And the result will be (with iReport preview):
I've used the str() method and the $R{} syntax.

Conditional Horizontal line in jasperreport between results

I'm using jasperreport 4.7.0
I have a query where I order by name then date .
Now the clients wants that when the name changes that we add an horizontal line (see attached img - red line)
Is there a way to accomplish this without duplicating the query and the fields ?
Result :
For solving your task you can use Data Grouping.
The possible steps (there are a lot of way to reach your target) for adding line are:
Create the report Group (via context menu Add Report Group in iReport) on field
Add Group Footer Band
Add Rectangle element to the Group Footer Band
Set Height, Forecolor and Backcolor for this Rectangle - drawing "red pencil line"
The sample:
<?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="line_in_group" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f1394ead-7ad6-4371-979d-5a13d1bdde4d">
<queryString>
<![CDATA[SELECT id, city, street FROM address ORDER BY city]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="CITY" class="java.lang.String"/>
<field name="STREET" class="java.lang.String"/>
<group name="cityGroup">
<groupExpression><![CDATA[$F{CITY}]]></groupExpression>
<groupFooter>
<band height="2">
<rectangle>
<reportElement uuid="6564e743-2a45-4b51-89a5-e3ec6aee291f" x="0" y="0" width="300" height="2" forecolor="#FF0000" backcolor="#FF0000"/>
</rectangle>
</band>
</groupFooter>
</group>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement uuid="77860b22-95f6-41b6-955a-f8991843e221" x="0" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[ID]]></text>
</staticText>
<staticText>
<reportElement uuid="77860b22-95f6-41b6-955a-f8991843e221" x="100" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[City]]></text>
</staticText>
<staticText>
<reportElement uuid="77860b22-95f6-41b6-955a-f8991843e221" x="200" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Street]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="7e375aa3-fab5-4761-bab9-a0570a5442b1" x="0" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="7e375aa3-fab5-4761-bab9-a0570a5442b1" x="100" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{CITY}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="7e375aa3-fab5-4761-bab9-a0570a5442b1" x="200" y="0" width="100" height="20"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{STREET}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
The result will be (via preview in iReport):
In this sample I've create a group for the field CITY.