Jasper Report Heading on new page - jasper-reports

I have a report that contains lists that I iterate over to display a title and then some contents. If the contents are too long the report spans more than 1 page. Depending on how much space this left on the overflow page the title is displayed on the overflow page or pushed to the following page. I always want it to be pushed to the following page. I have tried to use elementGroup and group to try and make sure that everything is keep together, but nothing seems to work. The report looks like this:
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3 -->
<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_Latest" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a3bcc82f-7412-423e-b109-7a84c111800f">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Localhost Mongo"/>
<subDataset name="productDetails" uuid="e21ddc86-6be3-47de-8a73-e0f836ddd976">
<field name="product" class="java.util.List">
<fieldDescription><![CDATA[product]]></fieldDescription>
</field>
<field name="features" class="java.util.List">
<fieldDescription><![CDATA[features]]></fieldDescription>
</field>
</subDataset>
<subDataset name="interviewQuestionDetails" uuid="143b235e-1410-4d07-a21c-2757f36193f2">
<field name="questionText" class="java.lang.String">
<fieldDescription><![CDATA[questionText]]></fieldDescription>
</field>
<field name="responseText" class="java.lang.String">
<fieldDescription><![CDATA[responseText]]></fieldDescription>
</field>
</subDataset>
<parameter name="fromDate" class="java.util.Date">
<defaultValueExpression><![CDATA[new Date(0)]]></defaultValueExpression>
</parameter>
<parameter name="formattedFromDate" class="java.lang.String" isForPrompting="false" evaluationTime="Late">
<defaultValueExpression><![CDATA[DATEFORMAT($P{fromDate}, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")]]></defaultValueExpression>
</parameter>
<parameter name="toDate" class="java.util.Date">
<defaultValueExpression><![CDATA[new Date()]]></defaultValueExpression>
</parameter>
<parameter name="formattedToDate" class="java.lang.String" isForPrompting="false" evaluationTime="Late">
<defaultValueExpression><![CDATA[DATEFORMAT($P{toDate}, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")]]></defaultValueExpression>
</parameter>
<parameter name="instrument" class="java.util.List"/>
<field name="instr" class="java.lang.String"/>
<field name="subjects" class="java.util.List"/>
<field name="purchaser" class="java.lang.String"/>
<field name="orderReference" class="java.lang.String"/>
<field name="businessUnit" class="java.lang.String"/>
<field name="serviceCode" class="java.lang.String"/>
<field name="field1" class="java.lang.String"/>
<field name="field2" class="java.lang.String"/>
<field name="field3" class="java.lang.String"/>
<field name="questions" class="java.util.List"/>
<detail>
<band height="300" splitType="Prevent">
<textField>
<reportElement isPrintRepeatedValues="false" x="0" y="10" width="555" height="30" isRemoveLineWhenBlank="true" uuid="cc984ca4-2e56-47ec-aeae-ab8ae5445a37"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA["Object: " + $F{instr}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="0" y="40" width="530" height="40" uuid="06fc31b9-564a-4b0f-ae22-5283b68d950b"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="productDetails" uuid="c5fd0b5b-723e-4216-8f9a-7dac0c38d2e4">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{subjects})]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="40" width="530">
<textField>
<reportElement x="0" y="0" width="500" height="20" uuid="d372c83e-bf42-4aa8-bbda-3841d5c069a6"/>
<textElement>
<font size="13" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[""+org.apache.commons.lang.StringUtils.join($F{product}.toArray(),", ") + ""]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="500" height="20" uuid="4208d514-f41e-4b37-814d-06d797c3a088"/>
<textFieldExpression><![CDATA["Features: "+org.apache.commons.lang.StringUtils.join($F{features}.toArray(),", ") + ""]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
<textField>
<reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="80" width="555" height="20" uuid="1c2e1d42-100d-4d1d-be01-9a089c1693ce"/>
<textFieldExpression><![CDATA["Purchaser: " + $F{purchaser}]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="Float" x="0" y="100" width="555" height="20" uuid="1c0a0e9f-59e1-4754-b5cc-f6d469e8617d"/>
<textFieldExpression><![CDATA["Order Reference: " + $F{orderReference}]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="Float" x="0" y="120" width="555" height="20" uuid="1c0a0e9f-59e1-4754-b5cc-f6d469e8617d"/>
<textFieldExpression><![CDATA["Unit: " + $F{businessUnit}]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="Float" x="0" y="140" width="555" height="20" uuid="1c0a0e9f-59e1-4754-b5cc-f6d469e8617d"/>
<textFieldExpression><![CDATA["Code: " + $F{serviceCode}]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="0" y="160" width="555" height="20" uuid="63032d3a-0cfe-441a-bb37-5a845b2e61c7"/>
<text><![CDATA[Content:]]></text>
</staticText>
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" x="20" y="180" width="535" height="20" uuid="c2c03017-b519-4675-8dd0-22b1ef374aa7"/>
<textFieldExpression><![CDATA["invoice pricing structure Executive innovate Multi-lateral digital transmit South Africa Bedfordshire deposit orange Money Market Account Michigan Technician infomediaries Rand Loti Cotton salmon Frozen Arizona Tasty Rubber Keyboard Mauritius Practical Metal Chicken channels Dynamic. invoice pricing structure Executive innovate Multi-lateral digital transmit South Africa Bedfordshire deposit orange Money Market Account Michigan Technician infomediaries Rand Loti Cotton salmon Frozen Arizona Tasty Rubber Keyboard Mauritius Practical Metal Chicken channels Dynamic. invoice pricing structure Executive innovate Multi-lateral digital transmit South Africa Bedfordshire deposit orange Money Market Account Michigan Technician infomediaries Rand Loti Cotton salmon Frozen Arizona Tasty Rubber Keyboard Mauritius Practical Metal Chicken channels Dynamic"]]></textFieldExpression>
</textField>
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" x="20" y="200" width="535" height="20" uuid="85d8213d-ea25-40c8-9d0c-07d289aaf716"/>
<textFieldExpression><![CDATA[$F{field2}]]></textFieldExpression>
</textField>
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" x="20" y="220" width="535" height="20" uuid="d2d98193-506a-418e-a66f-756402c75825"/>
<textFieldExpression><![CDATA[$F{field3}]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="0" y="240" width="555" height="20" uuid="63032d3a-0cfe-441a-bb37-5a845b2e61c7"/>
<text><![CDATA[Interview Questions]]></text>
</staticText>
<componentElement>
<reportElement positionType="Float" x="0" y="260" width="530" height="40" uuid="06fc31b9-564a-4b0f-ae22-5283b68d950b"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="interviewQuestionDetails" uuid="a66a2c1a-bba0-4858-b3ed-ee25a9bd28a1">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{questions})]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="40" width="530">
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" x="20" y="0" width="500" height="20" uuid="4b6eccd1-2234-40c3-ac88-256f621b784d"/>
<textFieldExpression><![CDATA[$F{questionText}]]></textFieldExpression>
</textField>
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" x="20" y="20" width="500" height="20" uuid="d74141e1-fef5-4b7f-85af-ccd041fe1162"/>
<textFieldExpression><![CDATA[$F{responseText}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
</jasperReport>
It's this section <textFieldExpression><![CDATA["Object: " + $F{instr}]]></textFieldExpression> that I also want to be displayed at the start of a new page. Can I use isPrintInFirstWholeBand="true" on the reportElement? I can't seem to get this to work or a group with keepTogether="true" or isStartNewPage="true". Not sure what to use. Just want each Object: value to be displayed at the start of a new page.

try using isIgnorePagination="true" property
or check Ignore Pagination in Report where you set Page Format and so...

Related

How to split details across multiple columns while programmatically appending 'continuation' message for subsequent sections?

I have a customer request to split details of personal information (name, address, secondary addresses, etc) across multiple columns, if the dynamic size does not fit in the current column. As a caveat, the name field, followed by the word '(Continued)', is desired, as the title for the segments in subsequent columns.
Is this behavior possible with jasper-reports?
I have tried toggling an 'inBetween' flag with the beforeDetailEval() and afterDetailEval() hooks, checking that flag in the column header band, to optionally reprint the name + 'Continued', but the column header always calls the scriptlet method AFTER the afterDetailEval() method (does not make sense to my little mind), failing since the 'inBetween' flag is reset to false.
(Note: Detail band has been set with splitType to both 'Immediate' and 'Stretch', but neither approach has behaved as expected. The entire band just gets restarted at the beginning of the next column)
Is this possible, and if so, are there any suggestions for creative solutions for this scenario?
Also, there is strange behavior displaying where if a detail is split across multiple columns, the first part of the detail (up to the subreport element)is duplicated on the following column. This behavior is also undesirable to the customer, and needs to be adjusted so nothing (except the title) is duplicated.
This is the syntax desired by the customer:
Name 1 Name 2
Address 1 (Continued)
City 1 AL – Address 3
State 1 AL - City 3
Zip 1 AL - State 3
Additional Locations: AL - Zip 3
AL-Address 1 ...
AL-City 1
AL-State 1
AL-Zip 1
AL-Address 2
AL-City 2
AL-State 2
AL-Zip 2
Name 2
Address 2
City 2
State 2
Zip 2
Additional Locations:
AL-Address 1
AL – City 1
AL-State 1
AL – Zip 1
AL – Address 2
AL – City 2
AL – State 2
AL – Zip 2
This is what we are actually getting:
Name1 Name1
Address1 Address1
City1 City1
State1 State1
Zip1 Zip1
Additional Locations Additional Locations
AL-Name1 AL-City2
AL-Address1 AL-State2
AL-City1 AL-State2
AL-State1
AL-Zip1
AL-Name2
AL-Address2
This is a sample main jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-22T09:48:08 -->
<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" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" scriptletClass="path.to.my.scriptlet" uuid="af53d807-7975-4ff7-bfc5-e438944aa795">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Name" class="java.lang.String"/>
<field name="Address" class="java.lang.String"/>
<field name="City" class="java.lang.String"/>
<field name="State" class="java.lang.String"/>
<field name="Zip" class="java.lang.String"/>
<field name="AdditionalLocations" class="java.util.List"/>
<variable name="IN_MIDDLE_OF_DETAIL" class="java.lang.Boolean" calculation="System">
<initialValueExpression><![CDATA[Boolean.False]]></initialValueExpression>
</variable>
<columnHeader>
<band height="74" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="-10" y="0" width="100" height="30" uuid="258dce49-fb61-4887-bb30-69e80e96d8f1">
<printWhenExpression><![CDATA[$V{IN_MIDDLE_OF_DETAIL}]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="-10" y="40" width="100" height="30" uuid="c18b2fab-900b-4641-aaef-2520510a3510">
<printWhenExpression><![CDATA[$V{IN_MIDDLE_OF_DETAIL}]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA["(CONTINUED)"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="426" splitType="Stretch">
<textField>
<reportElement x="0" y="10" width="100" height="30" uuid="853a1b0d-a49e-45c4-8183-83cfd69bf5af"/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="50" width="100" height="30" uuid="46697c6d-1c2f-422b-9170-6b2f36ce13ba"/>
<textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="90" width="100" height="30" uuid="31730cd5-0b17-452e-8a22-d16ea2061605"/>
<textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="120" width="100" height="30" uuid="b4a4c671-dc63-41b4-b080-9ad5b750bb58"/>
<textFieldExpression><![CDATA[$F{State}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="160" width="100" height="30" uuid="8f8bec7c-3d4a-466b-8b02-2bb82e61904d"/>
<textFieldExpression><![CDATA[$F{Zip}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="220" width="100" height="110" uuid="8ef583fd-fa23-47d8-80d0-90de4f6478a0"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{AdditionalLocations})]]></dataSourceExpression>
<subreportExpression><![CDATA["Blank_A4_1.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="10" y="198" width="100" height="30" uuid="4887e0c1-3da2-4350-9454-4a3e33c0fe71"/>
<text><![CDATA[Additional Locations]]></text>
</staticText>
</band>
</detail>
</jasperReport>
This is the sample subreport jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-22T10:39:43 -->
<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_1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9b8a1d93-2ee6-4d29-b9ec-7c56a3917729">
<queryString>
<![CDATA[]]>
</queryString>
<field name="Address" class="java.lang.String"/>
<field name="City" class="java.lang.String"/>
<field name="State" class="java.lang.String"/>
<field name="Zip" class="java.lang.String"/>
<detail>
<band height="168" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="10" width="100" height="30" uuid="3d74e624-6b6f-40e9-87d2-ddb5022668b2"/>
<textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="50" width="100" height="30" uuid="5df31fa3-38ee-44a4-8931-e8eef45fb7a6"/>
<textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="89" width="100" height="30" uuid="964a282f-54c7-44a3-954d-27d1c70d3d0c"/>
<textFieldExpression><![CDATA[$F{State}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="130" width="100" height="30" uuid="e1349222-d945-4dec-8454-e2d6e3fb6a2a"/>
<textFieldExpression><![CDATA[$F{Zip}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
This is the basic scriptlet code to toggle the value of IN_MIDDLE_OF_DETAIL:
#Override
public void beforeDetailEval() throws JRScriptletException
{
setVariableValue("IN_MIDDLE_OF_DETAIL", Boolean.TRUE)
}
#Override
public void afterDetailEval() throws JRScriptletException
{
setVariableValue("IN_MIDDLE_OF_DETAIL", Boolean.FALSE)
}
Drop the scriptlet, there is no need for this, lets use the fact that subreport's has its own page count, hence when it breaks in main report it counts a page
The solution I would use is the pageHeader band in the subreport with a printWhenExpression on page number (>1).
Which means that the text that you like to display when subreport splits to new "page" (name and "Continue") goes into pageHeader of the subreport and should be printed on all subreport "pages" except the first one.
Since name does not seems to be part of the subreport datasource I will pass this as a parameter to the subreport.
Code in subreport to display header when page > 1
<pageHeader>
<band height="44">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}>1]]></printWhenExpression>
<textField>
<reportElement x="0" y="0" width="220" height="20" uuid="8cce4cab-6ccf-4ddb-b1f1-508dc97bfcfe"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="220" height="19" uuid="c18b2fab-900b-4641-aaef-2520510a3510"/>
<textElement verticalAlignment="Middle">
<font isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["(Continued)"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
Example output
I have cut down page height to reduce image
Full example
**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="Blank_A4" columnCount="2" pageWidth="595" pageHeight="500" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="af53d807-7975-4ff7-bfc5-e438944aa795">
<queryString>
<![CDATA[]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<field name="zip" class="java.lang.String"/>
<field name="additionalLocations" class="java.util.List"/>
<detail>
<band height="141" splitType="Immediate">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="20" width="280" height="20" uuid="46697c6d-1c2f-422b-9170-6b2f36ce13ba">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="40" width="280" height="20" uuid="31730cd5-0b17-452e-8a22-d16ea2061605"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="60" width="280" height="20" uuid="b4a4c671-dc63-41b4-b080-9ad5b750bb58"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{state}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="80" width="280" height="20" uuid="8f8bec7c-3d4a-466b-8b02-2bb82e61904d"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zip}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="120" width="280" height="20" isPrintWhenDetailOverflows="true" uuid="8ef583fd-fa23-47d8-80d0-90de4f6478a0"/>
<subreportParameter name="name">
<subreportParameterExpression><![CDATA[$F{name}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{additionalLocations})]]></dataSourceExpression>
<subreportExpression><![CDATA["C:/Users/pette/JaspersoftWorkspace/MyReports/SplitSubreport.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="0" y="100" width="280" height="20" uuid="4887e0c1-3da2-4350-9454-4a3e33c0fe71"/>
<textElement verticalAlignment="Middle">
<font isItalic="false" isUnderline="true"/>
</textElement>
<text><![CDATA[Additional Locations]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="280" height="20" uuid="258dce49-fb61-4887-bb30-69e80e96d8f1"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
**subreport 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="Blank_A4_1" pageWidth="280" pageHeight="200" columnWidth="280" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="9b8a1d93-2ee6-4d29-b9ec-7c56a3917729">
<parameter name="name" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="address" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<field name="zip" class="java.lang.String"/>
<pageHeader>
<band height="44">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}>1]]></printWhenExpression>
<textField>
<reportElement x="0" y="20" width="220" height="19" uuid="c18b2fab-900b-4641-aaef-2520510a3510"/>
<textElement verticalAlignment="Middle">
<font isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["(Continued)"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="220" height="20" uuid="8cce4cab-6ccf-4ddb-b1f1-508dc97bfcfe"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{name}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="85" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="-1" width="220" height="21" uuid="3d74e624-6b6f-40e9-87d2-ddb5022668b2"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="20" width="220" height="20" uuid="5df31fa3-38ee-44a4-8931-e8eef45fb7a6"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="40" width="220" height="20" uuid="964a282f-54c7-44a3-954d-27d1c70d3d0c"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{state}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="60" width="220" height="20" uuid="e1349222-d945-4dec-8454-e2d6e3fb6a2a"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zip}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

iReport Text Field Spacing Issues

My report is showing some very odd spacing issues. It had values that were being repeated, muliple times, but i fixed that by unselecting the Print Repeated Values check box. This fixed the repeated values from displaying. Afterwards I noticed that there were some spaces that were showing up after unselecting that so I then selected the Remove Line When Blank check box. That should have fixed the spacing but for some odd reason I am still seeing some very odd spacing issues in the Preview of my report. Here are some pictures showing what I have. Does anyone have any idea why it would still be doing this; even after I have done the correct options for spacing/repeating values?
Spacing Issue:
Shows the Checked Property boxes for all 'Text Fields'
<?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="BOM Build Time" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="775a7e35-9af8-4206-a155-b05a478c35b0">
<property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="bomNumber" class="java.lang.String"/>
<parameter name="From" class="java.util.Date"/>
<parameter name="To" class="java.util.Date"/>
<queryString>
<![CDATA[SELECT
datediff(day,MO."DATECREATED",MO."DATECOMPLETED") AS dayToBuild,
COMPANY."NAME" AS COMPANY_NAME,
BOM."NUM" AS BOM_NUM,
MO."DATECREATED" AS MO_DATECREATED,
MO."NUM" AS MO_NUM,
MO."DATECOMPLETED" AS MO_DATECOMPLETED,
MOITEM."BOMID" AS MOITEM_BOMID,
MOITEM."MOID" AS MOITEM_MOID,
MOITEM."QTYTOFULFILL" AS MOITEM_QTYTOFULFILL,
BOMITEMTYPE."ID" AS BOMITEMTYPE_ID
FROM
"BOM" BOM INNER JOIN "MOITEM" MOITEM ON BOM."ID" = MOITEM."BOMID"
INNER JOIN "MO" MO ON MOITEM."MOID" = MO."ID"
INNER JOIN "BOMITEMTYPE" BOMITEMTYPE ON MOITEM."TYPEID" = BOMITEMTYPE."ID",
"COMPANY" COMPANY
WHERE
BOM."NUM"=$P{bomNumber}
AND MO."DATECOMPLETED" BETWEEN $P{To} AND $P{From}
ORDER BY
3 ASC]]>
</queryString>
<field name="DAYTOBUILD" class="java.lang.Long"/>
<field name="COMPANY_NAME" class="java.lang.String"/>
<field name="BOM_NUM" class="java.lang.String"/>
<field name="MO_DATECREATED" class="java.sql.Timestamp"/>
<field name="MO_NUM" class="java.lang.String"/>
<field name="MO_DATECOMPLETED" class="java.sql.Timestamp"/>
<field name="MOITEM_BOMID" class="java.lang.Integer"/>
<field name="MOITEM_MOID" class="java.lang.Integer"/>
<field name="MOITEM_QTYTOFULFILL" class="java.lang.Double"/>
<field name="BOMITEMTYPE_ID" class="java.lang.Integer"/>
<variable name="timeToBuild" class="java.lang.String">
<variableExpression><![CDATA[($F{MO_DATECOMPLETED}.getTime()- $F{MO_DATECREATED}.getTime()) / (24* 60 * 60 * 1000) + " days " +
(($F{MO_DATECOMPLETED}.getTime()-$F{MO_DATECREATED}.getTime()) / (60 * 60 * 1000)) % 24 + " hour(s), " +
(($F{MO_DATECOMPLETED}.getTime()-$F{MO_DATECREATED}.getTime()) / (60 * 1000)) % 60 + " minute(s)"]]></variableExpression>
</variable>
<variable name="avgTimeToBuild" class="java.lang.String" incrementType="Report" calculation="Count">
<variableExpression><![CDATA[$V{timeToBuild}]]></variableExpression>
</variable>
<title>
<band height="33" splitType="Stretch"/>
</title>
<columnHeader>
<band height="32" splitType="Stretch">
<staticText>
<reportElement x="0" y="1" width="100" height="20" uuid="b59f6065-7fc9-482d-9e08-e381ac697304"/>
<text><![CDATA[BOM_NUM]]></text>
</staticText>
<staticText>
<reportElement x="108" y="0" width="100" height="20" uuid="4ec40990-bdfe-415d-a7ae-b50e315d00ef"/>
<text><![CDATA[MO_DATECREATED]]></text>
</staticText>
<staticText>
<reportElement x="218" y="0" width="100" height="20" uuid="032d2ae9-99fe-4c6f-8cf4-24b9c5367a44"/>
<text><![CDATA[MO_DATECOMPLETED]]></text>
</staticText>
<staticText>
<reportElement x="329" y="0" width="150" height="20" uuid="55b731d5-b826-4ee1-b7d2-4a83cabd4ef8"/>
<text><![CDATA[Time To Build]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="24" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true" uuid="3b256693-f18d-4ef9-89ec-7890481d1855"/>
<textFieldExpression><![CDATA[$F{BOM_NUM}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="108" y="0" width="100" height="20" isRemoveLineWhenBlank="true" uuid="7c01356e-4c95-4e15-9691-632e0b84946e"/>
<textFieldExpression><![CDATA[$F{MO_DATECREATED}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="218" y="0" width="100" height="20" isRemoveLineWhenBlank="true" uuid="516bc38e-99f3-486f-ae74-c8cfe6a5b5b1"/>
<textFieldExpression><![CDATA[$F{MO_DATECOMPLETED}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="329" y="0" width="150" height="20" isRemoveLineWhenBlank="true" uuid="aa538d4a-48ec-4b72-84ed-e9e889dcaee5"/>
<textElement>
<paragraph tabStopWidth="40"/>
</textElement>
<textFieldExpression><![CDATA[$V{timeToBuild}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="479" y="0" width="76" height="20" isRemoveLineWhenBlank="true" uuid="cf252514-6297-405d-a12e-6424332e6d10"/>
<textFieldExpression><![CDATA[$F{MOITEM_QTYTOFULFILL}]]></textFieldExpression>
</textField>
</band>
</detail>
<summary>
<band height="22">
<staticText>
<reportElement x="0" y="0" width="125" height="20" uuid="5ac0e1eb-dc7b-4866-88aa-3c1a9c3ef4a9"/>
<text><![CDATA[Average Time To Build:]]></text>
</staticText>
<textField>
<reportElement x="125" y="0" width="150" height="20" uuid="860dd902-9791-443e-9a9d-3dedab365b23"/>
<textFieldExpression><![CDATA[$V{avgTimeToBuild}]]></textFieldExpression>
</textField>
</band>
</summary>

How to create a jasper report that manage overflow in next page?

i would like to know if is possible have a report that has a lot of fields that manage automatically the overflow in other page. I would put every field in detail tag and i would like that when there is some element that goes outside of detail area, it could be appear in the next one. Below i posted my jasper report:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.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="SvamaTemplate" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="335f8e22-f47d-4b34-abcd-a6682c0cf7b4">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="SvamaTemplateXML"/>
<queryString language="xPath">
<![CDATA[/]]>
</queryString>
<field name="id" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/#id]]></fieldDescription>
</field>
<field name="potenziale_residuo_vpot" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="potenziale_residuo_vpot"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="supporto_rete_sociale" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="supporto_rete_sociale"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="pulizia_casa" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="pulizia_casa"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="lavanderia" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="lavanderia"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="effettuazione_acquisti" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="effettuazione_acquisti"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="bagno" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="bagno"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="toiletta" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="toiletta"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="abbigliamento1" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="abbigliamento1"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="uso_wc" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="uso_wc"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="assuzione_medicinali" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="assuzione_medicinali"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="trasferimenti" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="trasferimenti"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="deambulazione1" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="deambulazione1"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="gestione_denaro" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="gestione_denaro"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="sostegno_psicoaffettivo" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="sostegno_psicoaffettivo"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="supervisione_diurna" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="supervisione_diurna"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<field name="supervisione_notturna" class="java.lang.String">
<fieldDescription><![CDATA[/svama/sections/section/subsection/selectOneRadio[#id="supervisione_notturna"]/items/item[#selected="true"]/value/text()]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="47" splitType="Stretch">
<staticText>
<reportElement x="230" y="8" width="100" height="30" uuid="91c6fde2-503f-4228-8cf0-e2878b9fdb3b"/>
<textElement textAlignment="Center">
<font size="20" isBold="true"/>
</textElement>
<text><![CDATA[SVAMA]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="13" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="13" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="270" splitType="Stretch">
<textField>
<reportElement x="130" y="120" width="424" height="30" uuid="74e0b517-f4c9-4679-a8d2-54e7f4582a3e"/>
<textFieldExpression><![CDATA[$F{pulizia_casa}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="120" width="110" height="30" uuid="40f82bd5-9d95-45b3-b21d-c7f738c576c5"/>
<text><![CDATA[pulizia_casa]]></text>
</staticText>
<textField>
<reportElement x="130" y="200" width="424" height="30" uuid="f8c91c60-26bb-419e-87a7-8b2dd158b83b"/>
<textFieldExpression><![CDATA[$F{effettuazione_acquisti}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="200" width="110" height="30" uuid="e2d4b4b2-5c98-4041-9b94-36aa7e2c53e5"/>
<text><![CDATA[effettuazione_acquisti]]></text>
</staticText>
<!-- break is attempt, i don't know what should put here -->
<break>
<reportElement x="0" y="270" width="517" height="1" uuid="08ff5b1a-7ff4-4848-ba95-e9ce31d0d44e"/>
</break>
<staticText>
<reportElement x="10" y="280" width="110" height="30" uuid="e2d4b4b2-5c98-4041-9b94-36aa7e2c53e5"/>
<text><![CDATA[toiletta]]></text>
</staticText>
<textField>
<reportElement x="130" y="280" width="424" height="30" uuid="f8c91c60-26bb-419e-87a7-8b2dd158b83b"/>
<textFieldExpression><![CDATA[$F{toiletta}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="320" width="110" height="30" uuid="e2d4b4b2-5c98-4041-9b94-36aa7e2c53e5"/>
<text><![CDATA[abbigliamento1]]></text>
</staticText>
<textField>
<reportElement x="130" y="320" width="424" height="30" uuid="f8c91c60-26bb-419e-87a7-8b2dd158b83b"/>
<textFieldExpression><![CDATA[$F{abbigliamento1}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="360" width="110" height="30" uuid="e2d4b4b2-5c98-4041-9b94-36aa7e2c53e5"/>
<text><![CDATA[uso_wc]]></text>
</staticText>
<textField>
<reportElement x="130" y="360" width="424" height="30" uuid="f8c91c60-26bb-419e-87a7-8b2dd158b83b"/>
<textFieldExpression><![CDATA[$F{uso_wc}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="440" width="110" height="30" uuid="e2d4b4b2-5c98-4041-9b94-36aa7e2c53e5"/>
<text><![CDATA[trasferimenti]]></text>
</staticText>
<textField>
<reportElement x="130" y="440" width="424" height="30" uuid="f8c91c60-26bb-419e-87a7-8b2dd158b83b"/>
<textFieldExpression><![CDATA[$F{trasferimenti}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="520" width="110" height="30" uuid="e2d4b4b2-5c98-4041-9b94-36aa7e2c53e5"/>
<text><![CDATA[gestione_denaro]]></text>
</staticText>
<textField>
<reportElement x="130" y="520" width="424" height="30" uuid="f8c91c60-26bb-419e-87a7-8b2dd158b83b"/>
<textFieldExpression><![CDATA[$F{gestione_denaro}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="560" width="110" height="30" uuid="e2d4b4b2-5c98-4041-9b94-36aa7e2c53e5"/>
<text><![CDATA[sostegno_psicoaffettivo]]></text>
</staticText>
<textField>
<reportElement x="130" y="560" width="424" height="30" uuid="f8c91c60-26bb-419e-87a7-8b2dd158b83b"/>
<textFieldExpression><![CDATA[$F{sostegno_psicoaffettivo}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="640" width="110" height="30" uuid="e2d4b4b2-5c98-4041-9b94-36aa7e2c53e5"/>
<text><![CDATA[supervisione_notturna]]></text>
</staticText>
<textField>
<reportElement x="130" y="640" width="424" height="30" uuid="f8c91c60-26bb-419e-87a7-8b2dd158b83b"/>
<textFieldExpression><![CDATA[$F{supervisione_notturna}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
Does anyone have any idea? Thanks in advance.
Try changing:
<detail>
<band height="270" splitType="Stretch">
to
<detail>
<band height="270" splitType="Immediate">
In case it starts printing a blank page at the end, you might want to use:
<detail>
<band height="270" splitType="Prevent">
Instead

Show subreport independent of master datasource (master report) in ireport

Well, i have a Master and a SubReport where in master report i have 2 detail bands. In first detail band i put the "main datasource" (from fillReport), and in detail band 2 i put the subreport (datasource from a param).
My master report is configured to display "All Sections, No Detail" but the problem is that when "main datasource" dont have records the subreport isn't showed. I need show subreport detail independent of content of "main datasource".
How can i do it?
This is my report XML:
<?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="rf002" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="575" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" uuid="4436a245-e7f4-426f-aabc-806179a89e8a">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="84"/>
<parameter name="pathSubreport" class="java.lang.String">
<defaultValueExpression><![CDATA["/home/ronaldo/workspace/sender/src/main/webapp/WEB-INF/report/"]]></defaultValueExpression>
</parameter>
<parameter name="titulo" class="java.lang.String"/>
<parameter name="endereco" class="java.lang.String"/>
<parameter name="cep" class="java.lang.String"/>
<parameter name="estado" class="java.lang.String"/>
<parameter name="cidade" class="java.lang.String"/>
<parameter name="razaoSocial" class="java.lang.String"/>
<parameter name="pathLogomarca" class="java.lang.String"/>
<parameter name="usuario" class="java.lang.String"/>
<parameter name="dataFechamento" class="java.util.Date"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/home/ronaldo/workspace/odontonew/src/main/webapp/WEB-INF/report/"]]></defaultValueExpression>
</parameter>
<parameter name="totaltt" class="java.lang.Double"/>
<parameter name="dentista" class="br.com.odontonew.bean.Dentista"/>
<parameter name="historicosCaixaDentista" class="java.lang.Object"/>
<parameter name="historicosPagamentoOrcamento" class="java.lang.Object"/>
<parameter name="parcelasAVencerHoje" class="java.lang.Object"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="nomePaciente" class="java.lang.String">
<fieldDescription><![CDATA[orcamento.paciente.pessoaFisica.nome]]></fieldDescription>
</field>
<field name="dataHoraConsulta" class="java.sql.Timestamp">
<fieldDescription><![CDATA[dataHoraAgendada]]></fieldDescription>
</field>
<field name="idConsulta" class="java.lang.Integer">
<fieldDescription><![CDATA[id]]></fieldDescription>
</field>
<field name="nomeProcedimento" class="java.lang.String">
<fieldDescription><![CDATA[itens.itemTabelaProcedimento.procedimento.nome]]></fieldDescription>
</field>
<field name="isConcluido" class="java.lang.Boolean">
<fieldDescription><![CDATA[itens.concluido]]></fieldDescription>
</field>
<group name="consulta">
<groupExpression><![CDATA[$F{idConsulta}]]></groupExpression>
<groupHeader>
<band height="33">
<textField isBlankWhenNull="true">
<reportElement x="8" y="16" width="276" height="14" uuid="fd8d4206-2b32-4619-a340-95b4357b6a1a"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{nomePaciente}]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="true">
<reportElement x="292" y="16" width="184" height="14" uuid="e7b1cb6b-c4c4-42ab-b028-69e720f43f1f"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{dataHoraConsulta}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="9" y="5" width="149" height="12" uuid="bf06788d-c15a-4547-8a6e-df2ae3be70ea"/>
<textElement>
<font size="8"/>
</textElement>
<text><![CDATA[Paciente da Consulta]]></text>
</staticText>
<staticText>
<reportElement x="292" y="5" width="149" height="12" uuid="4d788cff-e015-4085-a320-8924a6a6b48c"/>
<textElement>
<font size="8"/>
</textElement>
<text><![CDATA[Data e Hora da Consulta]]></text>
</staticText>
</band>
</groupHeader>
</group>
<background>
<band/>
</background>
<title>
<band height="90" splitType="Stretch">
<subreport>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="575" height="90" uuid="0999674d-9841-41dd-97c2-226b2186b45e"/>
<subreportParameter name="pathLogomarca">
<subreportParameterExpression><![CDATA[$P{pathLogomarca}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="cidade">
<subreportParameterExpression><![CDATA[$P{cidade}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="titulo">
<subreportParameterExpression><![CDATA[$P{titulo}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="cep">
<subreportParameterExpression><![CDATA[$P{cep}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="estado">
<subreportParameterExpression><![CDATA[$P{estado}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="usuario">
<subreportParameterExpression><![CDATA[$P{usuario}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="razaoSocial">
<subreportParameterExpression><![CDATA[$P{razaoSocial}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="endereco">
<subreportParameterExpression><![CDATA[$P{endereco}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{pathSubreport}+"headerTemplate.jasper"]]></subreportExpression>
</subreport>
</band>
</title>
<columnHeader>
<band height="76">
<rectangle>
<reportElement x="0" y="27" width="575" height="49" backcolor="#DFDCDC" uuid="4e1f0879-74cc-46bf-8fb2-bb60ea002018"/>
<graphicElement>
<pen lineWidth="0.0"/>
</graphicElement>
</rectangle>
<staticText>
<reportElement x="416" y="57" width="140" height="14" uuid="afd4b28f-8b51-43d1-a9a2-c4acbb1f6c63"/>
<textElement textAlignment="Center">
<font isBold="true"/>
</textElement>
<text><![CDATA[Concluído]]></text>
</staticText>
<staticText>
<reportElement x="7" y="57" width="397" height="14" uuid="2c8deaa8-9d46-4c31-a542-e41b7f959615"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Procedimento]]></text>
</staticText>
<staticText>
<reportElement x="9" y="34" width="397" height="14" uuid="6578bf15-8e39-4a0d-9fc6-5c45fb5ad566"/>
<textElement>
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Consultas Realizadas]]></text>
</staticText>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
<reportElement x="120" y="5" width="165" height="14" uuid="4a835664-78da-4231-b7de-a21b730b4a7e"/>
<textFieldExpression><![CDATA[$P{dataFechamento}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="6" y="5" width="112" height="14" uuid="8420da3e-43c6-49a6-a688-89d50b5095a7"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Data Fechamento:]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="21">
<textField isBlankWhenNull="true">
<reportElement x="10" y="4" width="394" height="14" uuid="0f1109a2-30d7-4789-bb6f-54d066856cf3"/>
<textFieldExpression><![CDATA[$F{nomeProcedimento}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="425" y="1" width="131" height="14" uuid="6b67a6ee-6732-48b6-b79e-12f6e371c35e"/>
<textFieldExpression><![CDATA[$F{isConcluido} ? "Sim" : "Não"]]></textFieldExpression>
</textField>
</band>
<band height="173">
<subreport>
<reportElement x="0" y="0" width="575" height="73" uuid="871e12c8-2633-4d76-8d65-ce253710c4eb"/>
<dataSourceExpression><![CDATA[$P{historicosPagamentoOrcamento}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "rf002_historicosPagamentoOrcamento.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="0" y="94" width="575" height="69" uuid="338fd0af-a2ca-453e-8777-0f49698ebb44"/>
<dataSourceExpression><![CDATA[$P{historicosCaixaDentista}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "rf002_historicosCaixa.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<lastPageFooter>
<band height="185" splitType="Stretch">
<textField evaluationTime="Report">
<reportElement x="516" y="155" width="40" height="20" uuid="3cd272a2-adde-48f0-9f1e-5d7f007b9a1f"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="436" y="155" width="80" height="20" uuid="7cc86ec7-b620-4c95-9147-1410b1a22054"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
</band>
</lastPageFooter>
</jasperReport>
SOLUTION
After a lot of research i saw that my concept about "main report" and "subreport" is wrong. When we have a "main report" (associated with a main datasource) the correct is that all "subreport" is directly associated with this. So, i created 3 subreports and pass all datasources like a 'param'. In JasperManagerFillReport i passed a "JREmptyDataSource" to avoid the blank page because "main datasource" don't have any content.
You can try setting WhenNoData property to NoDataSection. Then, in the No Data band add what you want.
Also, check what happens to the subreports when the parameters you send as dataSourceExpression are empty (if they are).

Report designing issue using iReport

I am designing an invoice using iReport but i am having a problem with formatting.
I have to print invoice on letter head, where there are fixed positions to print the fields for example the total Amount has to get printed inside the box fixed at some location.
This is format of letter head:
At the bottom there is a field where total amount has to get printed, but i am not able to do so.
My output using iReport:
Screen Shot of iReport
This is my 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="LetterHeadInvoice" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<parameter name="COMPANY_ADDRESS" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="COMPANY_NAME" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="INVOICENO" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT DISTINCT c.docketno,c.bookingdate,c.rname,c.rcity,c.rcountry
,c.noofitems,c.actualweight,c.volweight,p.docketcharges,p.weight as weightused,
p.total,i.type,c.sname,c.scity,c.scountry,c.bookingdate,s.fovtype ,s.fovamount,s.oditype ,s.odiamount,s.nformtype ,s.nformamount,o.fsetype,o.fseamount
FROM typedetails i,paymentdetails p,clientdetails c,subdetails s,otherdetails o
WHERE i.id=c.typeid
AND c.docketno=p.docketno
And c.docketno= s.docketno
And c.docketno= o.docketno
AND c.docketno IN (SELECT docketnumber FROM invoice WHERE InvoiceId=$P{INVOICENO})]]>
</queryString>
<field name="docketno" class="java.lang.String"/>
<field name="bookingdate" class="java.sql.Timestamp"/>
<field name="rname" class="java.lang.String"/>
<field name="rcity" class="java.lang.String"/>
<field name="rcountry" class="java.lang.String"/>
<field name="noofitems" class="java.lang.Integer"/>
<field name="actualweight" class="java.math.BigDecimal"/>
<field name="volweight" class="java.lang.Short"/>
<field name="docketcharges" class="java.lang.Integer"/>
<field name="weightused" class="java.lang.Integer"/>
<field name="total" class="java.lang.Integer"/>
<field name="type" class="java.lang.String"/>
<field name="sname" class="java.lang.String"/>
<field name="scity" class="java.lang.String"/>
<field name="scountry" class="java.lang.String"/>
<field name="fovtype" class="java.lang.String"/>
<field name="fovamount" class="java.lang.String"/>
<field name="oditype" class="java.lang.String"/>
<field name="odiamount" class="java.lang.String"/>
<field name="nformtype" class="java.lang.String"/>
<field name="nformamount" class="java.lang.String"/>
<field name="fsetype" class="java.lang.String"/>
<field name="fseamount" class="java.lang.Integer"/>
<variable name="TOTAL" class="java.lang.Double" calculation="Sum">
<variableExpression><![CDATA[$F{total}]]></variableExpression>
</variable>
<variable name="TOTAL2" class="java.lang.Double" incrementType="Column" calculation="Sum">
<variableExpression><![CDATA[$V{TOTAL}+$F{fseamount}]]></variableExpression>
</variable>
<variable name="Tax" class="java.lang.Double">
<variableExpression><![CDATA[$V{TOTAL2}/100.00*12.36]]></variableExpression>
</variable>
<background>
<band height="802" splitType="Stretch">
<image>
<reportElement x="0" y="0" width="555" height="802"/>
<imageExpression><![CDATA["C:\\Documents and Settings\\Hemant\\Desktop\\RNZImage.jpg"]]></imageExpression>
</image>
</band>
</background>
<title>
<band height="205" splitType="Stretch">
<staticText>
<reportElement x="40" y="61" width="40" height="23"/>
<textElement>
<font fontName="Lucida Bright" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Bill To]]></text>
</staticText>
<textField>
<reportElement x="40" y="84" width="266" height="107"/>
<textElement>
<font size="11"/>
</textElement>
<textFieldExpression><![CDATA[$F{sname}+"\n"+$F{scity}+","+$F{scountry}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="324" y="95" width="91" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$P{INVOICENO}]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy">
<reportElement x="429" y="96" width="104" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField pattern="MMMMM-yy">
<reportElement x="312" y="145" width="83" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</title>
<detail>
<band height="112" splitType="Stretch">
<textField pattern="MM/dd/yyyy">
<reportElement x="28" y="31" width="52" height="20"/>
<textElement>
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{bookingdate}.toString().substring(0,$F{bookingdate}.toString().indexOf(" "))]]></textFieldExpression>
</textField>
<textField>
<reportElement x="82" y="31" width="54" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{docketno}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="164" y="31" width="77" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{rcity}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="261" y="31" width="35" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{rcity}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="306" y="31" width="33" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{noofitems}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="345" y="31" width="33" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{weightused}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="395" y="31" width="73" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{type}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="480" y="31" width="48" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{docketcharges}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="346" y="90" width="123" height="17" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA[$F{oditype}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="480" y="90" width="55" height="17" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA[$F{odiamount}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="346" y="56" width="123" height="17" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA[$F{fovtype}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="480" y="73" width="55" height="17" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA[$F{nformamount}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="346" y="73" width="123" height="17" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA[$F{nformtype}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="480" y="56" width="55" height="17" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA[$F{fovamount}]]></textFieldExpression>
</textField>
</band>
</detail>
<summary>
<band height="280" splitType="Stretch">
<textField>
<reportElement x="478" y="12" width="59" height="20"/>
<textElement markup="none"/>
<textFieldExpression><![CDATA[$V{TOTAL}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="334" y="32" width="128" height="17">
<printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA[$F{fsetype}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="478" y="32" width="59" height="17">
<printWhenExpression><![CDATA[$F{odiamount} != null && $F{odiamount}.trim().length()>0]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA[$F{fseamount}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="334" y="49" width="128" height="20"/>
<textElement/>
<text><![CDATA[TOTAL]]></text>
</staticText>
<staticText>
<reportElement x="334" y="12" width="128" height="20"/>
<textElement/>
<text><![CDATA[SUB TOTAL]]></text>
</staticText>
<textField pattern="###0.00">
<reportElement x="478" y="69" width="59" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{TOTAL2}/100.00*12.36]]></textFieldExpression>
</textField>
<textField>
<reportElement x="478" y="49" width="59" height="20"/>
<textElement markup="none"/>
<textFieldExpression><![CDATA[$V{TOTAL}+$F{fseamount}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="334" y="69" width="128" height="20"/>
<textElement/>
<text><![CDATA[Service Tax At 12.36%]]></text>
</staticText>
<textField pattern="###0.00">
<reportElement x="464" y="252" width="73" height="20"/>
<textElement>
<font size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{TOTAL2}+$V{Tax}]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>
You should try to change Position Type to Fix Relative to Bottom or Float for this textField (with $V{TOTAL2}+$V{Tax} expression).
<textField pattern="###0.00">
<reportElement positionType="FixRelativeToBottom" x="464" y="252" width="73" height="20"/>
<textElement>
<font size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{TOTAL2}+$V{Tax}]]></textFieldExpression>
</textField>