While printing resultset using jasper api, I am facing one problem.
Description :
Report format :
GroupA(GroupHeader)
SubGroupName(SubGroup Header)
....Data(Detail Section).....
Condition :
If my subgroup header or GroupHeader appears to be at the bottom of the page i want to insert a page break,so that both header sections as well as data appears on the next page.
Example :
Actual Output :
GroupA(GroupHeader)
SubGroupName(SubGroup Header)
<unwanted Pagebreak>
....Data(Detail Section).....
Expected Output :
I want to avoid unwanted Pagebreak.so that my output will look like ,
GroupA(GroupHeader)
SubGroupName(SubGroup Header)
....Data(Detail Section).....
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="Account Sub Sub Group Report" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" whenResourceMissingType="Empty">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="P_Company" class="java.lang.String" isForPrompting="false"/>
<parameter name="P_UserName" class="java.lang.String" isForPrompting="false"/>
<parameter name="P_Criteria" class="java.lang.Object" isForPrompting="false">
<defaultValueExpression><![CDATA["' '"]]></defaultValueExpression>
</parameter>
<parameter name="P_Criteria_Code" class="java.lang.String">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA["' '"]]></defaultValueExpression>
</parameter>
<parameter name="P_Criteria_Name" class="java.lang.String">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA["' '"]]></defaultValueExpression>
</parameter>
<parameter name="P_Criteria_Suid" class="java.lang.Integer">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA[-1]]></defaultValueExpression>
</parameter>
<parameter name="P_Criteria_String" class="java.lang.String" isForPrompting="false"/>
<parameter name="P_ReportName" class="java.lang.String" isForPrompting="false"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\Ankitha\\DIS\\ws\\dis-services\\src\\main\\resources\\report\\"]]></defaultValueExpression>
</parameter>
<queryString>
<![----Query String----]>
</queryString>
<field name="ACGR_NAME" class="java.lang.String"/>
<field name="ACSG_NAME" class="java.lang.String"/>
<field name="ACSG_NATURE" class="java.lang.String"/>
<field name="ACTP_NAME" class="java.lang.String"/>
<field name="ASSG_CODE" class="java.lang.String"/>
<field name="ASSG_NAME" class="java.lang.String"/>
<field name="ASSG_ISLIMITAPPLICABLE" class="java.lang.String"/>
<field name="ASSG_LIMITFROM" class="java.math.BigDecimal"/>
<field name="ASSG_LIMITTO" class="java.math.BigDecimal"/>
<field name="ASSG_ISBUDGETAPPLICABLE" class="java.lang.String"/>
<field name="ASSG_BUDGETAMOUNT" class="java.math.BigDecimal"/>
<field name="ASSG_SEQUENCE" class="java.math.BigDecimal"/>
<variable name="ReportTitle" class="java.lang.String">
<initialValueExpression><![CDATA[$R{label.report.assg.reporttitle}]]></initialValueExpression>
</variable>
<group name="AccountGroupName">
<groupExpression><![CDATA[$F{ACGR_NAME}]]></groupExpression>
<groupHeader>
<band height="17">
<line>
<reportElement isPrintRepeatedValues="false" x="0" y="0" width="802" height="1" printWhenGroupChanges="AccountGroupName"/>
<graphicElement>
<pen lineWidth="0.01"/>
</graphicElement>
</line>
<textField isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="0" y="1" width="802" height="16" forecolor="#8E6531"/>
<textElement verticalAlignment="Middle">
<font fontName="Verdana" size="11" isBold="true" isUnderline="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.accountGroupName}+" "+$F{ACGR_NAME}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
<group name="AccountSubGroupName">
<groupExpression><![CDATA[$F{ACSG_NAME}]]></groupExpression>
<groupHeader>
<band height="15">
<textField isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="802" height="15" forecolor="#404D71"/>
<box leftPadding="20"/>
<textElement verticalAlignment="Middle">
<font fontName="Verdana" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.accountSubGroupName}+" "+$F{ACSG_NAME}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="51" splitType="Stretch">
<subreport>
<reportElement stretchType="RelativeToBandHeight" x="1" y="0" width="801" height="51"/>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_Criteria_String">
<subreportParameterExpression><![CDATA[$P{P_Criteria_String}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_Criteria_Code">
<subreportParameterExpression><![CDATA[$P{P_Criteria_Code}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_UserName">
<subreportParameterExpression><![CDATA[$P{P_UserName}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_Company">
<subreportParameterExpression><![CDATA[$P{P_Company}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_ReportName">
<subreportParameterExpression><![CDATA[$V{ReportTitle}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_Criteria">
<subreportParameterExpression><![CDATA[$P{P_Criteria}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_Criteria_Suid">
<subreportParameterExpression><![CDATA[$P{P_Criteria_Suid}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_Criteria_Name">
<subreportParameterExpression><![CDATA[$P{P_Criteria_Name}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="REPORT_RESOURCE_BUNDLE">
<subreportParameterExpression><![CDATA[$P{REPORT_RESOURCE_BUNDLE}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "Header.jasper"]]></subreportExpression>
</subreport>
</band>
</title>
<columnHeader>
<band height="33">
<frame>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="802" height="33"/>
<box>
<pen lineWidth="0.01" lineColor="#333333"/>
<topPen lineWidth="0.01" lineColor="#333333"/>
<leftPen lineWidth="0.01" lineColor="#333333"/>
<bottomPen lineWidth="0.01" lineColor="#333333"/>
<rightPen lineWidth="0.01" lineColor="#333333"/>
</box>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="0" y="0" width="214" height="33" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" backcolor="#CCE6F5"/>
<box leftPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.name}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="214" y="0" width="79" height="33" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" backcolor="#CCE6F5"/>
<box leftPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.code}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="293" y="0" width="59" height="33" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" backcolor="#CCE6F5"/>
<box leftPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.accounttype}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="652" y="0" width="67" height="33" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" backcolor="#CCE6F5"/>
<box rightPadding="5"/>
<textElement textAlignment="Right" verticalAlignment="Top">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.budget}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="480" y="17" width="62" height="16" backcolor="#CCE6F5"/>
<box rightPadding="5"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.inhouselimitto}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="352" y="17" width="65" height="16" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" backcolor="#CCE6F5"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.applicable}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="542" y="17" width="47" height="16" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" backcolor="#CCE6F5"/>
<box leftPadding="5"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.sequence}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="589" y="17" width="63" height="16" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" backcolor="#CCE6F5"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.applicable}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" mode="Opaque" x="719" y="17" width="83" height="16" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" backcolor="#CCE6F5"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.nature}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="417" y="17" width="63" height="16" backcolor="#CCE6F5"/>
<box rightPadding="5"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.inhouselimitfrom}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="352" y="0" width="65" height="17" backcolor="#CCE6F5"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.limit}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="417" y="0" width="125" height="17" backcolor="#CCE6F5"/>
<box rightPadding="0"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.inhouselimit}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="542" y="0" width="47" height="17" backcolor="#CCE6F5"/>
<box leftPadding="5"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.reporting}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="589" y="0" width="63" height="17" backcolor="#CCE6F5"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.budgetappl}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="719" y="0" width="83" height="17" backcolor="#CCE6F5"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.report.assg.account}]]></textFieldExpression>
</textField>
</frame>
</band>
</columnHeader>
<detail>
<band height="19">
<rectangle>
<reportElement stretchType="RelativeToBandHeight" x="1" y="0" width="800" height="18" backcolor="#F2F2F2">
<printWhenExpression><![CDATA[new Boolean($V{PAGE_COUNT}.intValue() % 2 == 0)]]></printWhenExpression>
</reportElement>
<graphicElement>
<pen lineWidth="0.0"/>
</graphicElement>
</rectangle>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="653" y="0" width="67" height="18" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ASSG_BUDGETAMOUNT}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="543" y="0" width="47" height="18" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ASSG_SEQUENCE}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="481" y="0" width="62" height="18" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ASSG_LIMITTO}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="353" y="0" width="66" height="18" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ASSG_ISLIMITAPPLICABLE}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="419" y="0" width="61" height="18" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ASSG_LIMITFROM}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" mode="Transparent" x="1" y="0" width="214" height="18" isRemoveLineWhenBlank="true"/>
<box leftPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ASSG_NAME}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="590" y="0" width="63" height="18" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ASSG_ISBUDGETAPPLICABLE}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="215" y="0" width="79" height="18" isRemoveLineWhenBlank="true"/>
<box leftPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ASSG_CODE}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="294" y="0" width="59" height="18" isRemoveLineWhenBlank="true"/>
<box leftPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ACTP_NAME}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToBandHeight" x="720" y="0" width="82" height="18" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{ACSG_NATURE}]]></textFieldExpression>
</textField>
<break>
<reportElement x="0" y="18" width="800" height="1">
<printWhenExpression><![CDATA[new Boolean($V{AccountSubGroupName_COUNT}.intValue()<1)]]></printWhenExpression>
</reportElement>
</break>
</band>
</detail>
<pageFooter>
<band height="20">
<textField isStretchWithOverflow="true">
<reportElement stretchType="RelativeToBandHeight" x="652" y="1" width="113" height="19"/>
<textElement textAlignment="Right">
<font fontName="Verdana"/>
</textElement>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" evaluationTime="Report">
<reportElement stretchType="RelativeToBandHeight" x="765" y="1" width="37" height="19"/>
<textElement>
<font fontName="Verdana"/>
</textElement>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
</jasperReport>