Don\'t get custom FormatFactory to work by using JRParameter.REPORT_FORMAT_FACTORY parameter

0

Hi,

I'm woring with jasperreports 3.7.5

I'm trying to use a custom FormatFactoy implementation to handle the case of an empty string representation ( "" ) of the xml data for a date field. I implemented a class implementing FormatFactory which should handle that.

 

public class InvoicePrintFormatFactory implements FormatFactory {
 
    @Override
    public DateFormat createDateFormat(String string, Locale locale, TimeZone tz) {
        DateFormat format = new SimpleDateFormat(string, locale){
 
            @Override
            public Date parse(String source) throws ParseException {
                if((source == null) || (source.equals("")))
                    return null;
                return super.parse(source);
            }
 
        };
 
        return format;
    }
 
    @Override
    public NumberFormat createNumberFormat(String string, Locale locale) {
 
        NumberFormat format = new DecimalFormat(string){
 
            @Override
            public Number parse(String source) throws ParseException {
                if((source == null) || (source.equals("")))
                    return null;
                return super.parse(source);
            }
 
        };
 
        return format;
    }
 
 
}

My jrxml looks like this

<?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 <a href="http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"" target="_blank">http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"</a> name="defaultOrderFrame" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="455" leftMargin="70" rightMargin="70" topMargin="70" bottomMargin="56">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="185"/>
	<style name="Heading"/>
	<style name="Heading 1" markup="none" fontSize="16" isBold="true"/>
	<style name="table">
		<box>
			<pen lineWidth="1.0" lineColor="#000000"/>
		</box>
	</style>
	<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
	</style>
	<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
	</style>
	<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
	</style>
	<style name="table 1">
		<box>
			<pen lineWidth="1.0" lineColor="#000000"/>
		</box>
	</style>
	<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
	</style>
	<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
	</style>
	<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
	</style>
	<style name="Crosstab Data Text" hAlign="Center"/>
	<style name="Heading 4" fontSize="12" isBold="true" isItalic="true"/>
	<style name="table 2">
		<box>
			<pen lineWidth="1.0" lineColor="#000000"/>
		</box>
	</style>
	<style name="table 2_TH" mode="Opaque" backcolor="#FFFFFF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
	</style>
	<style name="table 2_CH" mode="Opaque" backcolor="#FFBFBF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
	</style>
	<style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
		<box>
			<pen lineWidth="0.5" lineColor="#000000"/>
		</box>
		<conditionalStyle>
			<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
			<style backcolor="#FFEFEF"/>
		</conditionalStyle>
	</style>
	<subDataset name="Company">
		<queryString language="xPath">
			<![CDATA[/PDFRequest/OrderData/BusinessPartner/Company]]>
		</queryString>
		<field name="name" class="java.lang.String">
			<fieldDescription><![CDATA[@name]]></fieldDescription>
		</field>
		<field name="city" class="java.lang.String">
			<fieldDescription><![CDATA[Address/@city]]></fieldDescription>
		</field>
		<field name="country" class="java.lang.String">
			<fieldDescription><![CDATA[Address/@country]]></fieldDescription>
		</field>
		<field name="postalCode" class="java.lang.String">
			<fieldDescription><![CDATA[Address/@postalCode]]></fieldDescription>
		</field>
		<field name="street" class="java.lang.String">
			<fieldDescription><![CDATA[Address/@street]]></fieldDescription>
		</field>
		<field name="businessType" class="java.lang.String">
			<fieldDescription><![CDATA[@businessType]]></fieldDescription>
		</field>
		<variable name="businessRelationString" class="java.lang.String">
			<variableExpression><![CDATA[$F{businessType}.equals("1") ? "Lieferant: " : ($F{businessType}.equals("2") ? "Kunde: " : "")]]></variableExpression>
			<initialValueExpression><![CDATA[""]]></initialValueExpression>
		</variable>
	</subDataset>
	<subDataset name="ItemVariant">
		<queryString language="XPath">
			<![CDATA[]]>
		</queryString>
		<field name="quantity" class="java.lang.String">
			<fieldDescription><![CDATA[@quantity]]></fieldDescription>
		</field>
		<field name="variantText" class="java.lang.String">
			<fieldDescription><![CDATA[@variantText]]></fieldDescription>
		</field>
		<field name="discount" class="java.lang.String">
			<fieldDescription><![CDATA[ancestor::Variant/@discount]]></fieldDescription>
		</field>
		<field name="quantityRow" class="java.lang.String">
			<fieldDescription><![CDATA[ancestor::Variant/@quantity]]></fieldDescription>
		</field>
		<field name="variantRow" class="java.lang.String">
			<fieldDescription><![CDATA[ancestor::Variant/@rowAttr]]></fieldDescription>
		</field>
		<field name="sum" class="java.lang.String">
			<fieldDescription><![CDATA[ancestor::Variant/@sum]]></fieldDescription>
		</field>
		<field name="sum1" class="java.lang.String">
			<fieldDescription><![CDATA[ancestor::Variant/@sum1]]></fieldDescription>
		</field>
		<field name="trolleygroup_price" class="java.lang.String">
			<fieldDescription><![CDATA[ancestor::Variant/@trolleygroup_price]]></fieldDescription>
		</field>
		<field name="descCol" class="java.lang.String">
			<fieldDescription><![CDATA[ancestor::Variants/@colAttr]]></fieldDescription>
		</field>
		<field name="descRow" class="java.lang.String">
			<fieldDescription><![CDATA[ancestor::Variants/@rowAttr]]></fieldDescription>
		</field>
	</subDataset>
	<parameter name="CurrencySymbol" class="java.lang.String">
		<defaultValueExpression><![CDATA["€"]]></defaultValueExpression>
	</parameter>
	<parameter name="PicturePath" class="java.lang.String">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="UdId" class="java.lang.String">
		<parameterDescription><![CDATA[]]></parameterDescription>
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<queryString language="xPath">
		<![CDATA[/PDFRequest/OrderData/Trolley/Item]]>
	</queryString>
	<field name="number" class="java.lang.String">
		<fieldDescription><![CDATA[@number]]></fieldDescription>
	</field>
	<field name="price" class="java.lang.String">
		<fieldDescription><![CDATA[@price]]></fieldDescription>
	</field>
	<field name="quantity" class="java.lang.String">
		<fieldDescription><![CDATA[@quantity]]></fieldDescription>
	</field>
	<field name="unit" class="java.lang.String">
		<fieldDescription><![CDATA[@unit]]></fieldDescription>
	</field>
	<field name="userName" class="java.lang.String">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/Author/@userName]]></fieldDescription>
	</field>
	<field name="OrderQuanitity" class="java.lang.String">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/TrolleyHeader/@quanitity]]></fieldDescription>
	</field>
	<field name="vatRate" class="java.lang.String">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/TrolleyHeader/@vatRate]]></fieldDescription>
	</field>
	<field name="OrderDescription" class="java.lang.String">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/OrderDescription]]></fieldDescription>
	</field>
	<field name="text1" class="java.lang.String">
		<fieldDescription><![CDATA[@text1]]></fieldDescription>
	</field>
	<field name="itemNetto" class="java.lang.String">
		<fieldDescription><![CDATA[@sum1]]></fieldDescription>
	</field>
	<field name="ItemDiscount" class="java.lang.String">
		<fieldDescription><![CDATA[@discount]]></fieldDescription>
	</field>
	<field name="OrderAbs" class="java.lang.String">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/TrolleyHeader/@sum2]]></fieldDescription>
	</field>
	<field name="OrderNetto" class="java.lang.String">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/TrolleyHeader/@sumNet]]></fieldDescription>
	</field>
	<field name="orderNo" class="java.lang.String">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/TrolleyHeader/@orderNo]]></fieldDescription>
	</field>
	<field name="OrderDiscount" class="java.lang.String">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/TrolleyHeader/@discount]]></fieldDescription>
	</field>
	<field name="brutto" class="java.lang.Double">
		<fieldDescription><![CDATA[/PDFRequest/OrderData/TrolleyHeader/@brutto]]></fieldDescription>
	</field>
	<field name="base" class="java.lang.String">
		<fieldDescription><![CDATA[@base]]></fieldDescription>
	</field>
	<field name="Variants" class="java.lang.String">
		<fieldDescription><![CDATA[Variants]]></fieldDescription>
	</field>
	<field name="deliveryDate" class="java.util.Date">
		<fieldDescription><![CDATA[@deliveryDate]]></fieldDescription>
	</field>
	<field name="deliveryMethods" class="java.lang.String">
		<fieldDescription><![CDATA[@deliveryMethods]]></fieldDescription>
	</field>
	<field name="deliveryTerms" class="java.lang.String">
		<fieldDescription><![CDATA[@deliveryTerms]]></fieldDescription>
	</field>
	<field name="paymentTerms" class="java.lang.String">
		<fieldDescription><![CDATA[@paymentTerms]]></fieldDescription>
	</field>
	<field name="text2" class="java.lang.String">
		<fieldDescription><![CDATA[@text2]]></fieldDescription>
	</field>
	<variable name="XmlDataSource" class="net.sf.jasperreports.engine.data.JRXmlDataSource">
		<variableExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></variableExpression>
		<initialValueExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></initialValueExpression>
	</variable>
	<variable name="ItemVariantSource" class="net.sf.jasperreports.engine.data.JRXmlDataSource">
		<variableExpression><![CDATA[$V{XmlDataSource}.subDataSource("/Item/Variants/Variant/colAttr")]]></variableExpression>
		<initialValueExpression><![CDATA[null]]></initialValueExpression>
	</variable>
	<variable name="isVariant" class="java.lang.Boolean" resetType="Group" resetGroup="item">
		<variableExpression><![CDATA[$V{XmlDataSource}.subDocument().getDocumentElement().hasChildNodes()]]></variableExpression>
		<initialValueExpression><![CDATA[$V{XmlDataSource}.subDocument().getDocumentElement().hasChildNodes()]]></initialValueExpression>
	</variable>
	<variable name="OrderDescription" class="java.lang.String">
		<variableExpression><![CDATA[($F{OrderDescription}.equals(null) || $F{OrderDescription}.equals("null") || $F{OrderDescription}.equals("(null)") || $F{OrderDescription}.equals("")) ? null : $F{OrderDescription}]]></variableExpression>
		<initialValueExpression><![CDATA[null]]></initialValueExpression>
	</variable>
	<variable name="OrderDeliveryMethod" class="java.lang.String">
		<variableExpression><![CDATA[($F{deliveryMethods}.equals("(null)") || $F{deliveryMethods}.equals(null) || $F{deliveryMethods}.equals("")) ? null : $F{deliveryMethods}]]></variableExpression>
		<initialValueExpression><![CDATA[null]]></initialValueExpression>
	</variable>
	<variable name="OrderDeliveryTerms" class="java.lang.String">
		<variableExpression><![CDATA[($F{deliveryTerms}.equals("(null)") || $F{deliveryTerms}.equals(null) || $F{deliveryTerms}.equals("")) ? null : $F{deliveryTerms}]]></variableExpression>
		<initialValueExpression><![CDATA[null]]></initialValueExpression>
	</variable>
	<variable name="OrderPaymentTerms" class="java.lang.String">
		<variableExpression><![CDATA[($F{paymentTerms}.equals("(null)") || $F{paymentTerms}.equals(null) ||$F{paymentTerms}.equals("")) ? null : $F{paymentTerms}]]></variableExpression>
		<initialValueExpression><![CDATA[null]]></initialValueExpression>
	</variable>
	<variable name="OrderNetto" class="java.lang.Double">
		<variableExpression><![CDATA[Double.parseDouble($F{OrderNetto}.toString())]]></variableExpression>
		<initialValueExpression><![CDATA[null]]></initialValueExpression>
	</variable>
	<group name="deliveryDate">
		<groupExpression><![CDATA[$F{deliveryDate}]]></groupExpression>
		<groupHeader>
			<band height="17">
				<printWhenExpression><![CDATA[!$F{deliveryDate}.equals("(null)")]]></printWhenExpression>
				<textField isStretchWithOverflow="true">
					<reportElement x="0" y="1" width="258" height="16" isPrintWhenDetailOverflows="true"/>
					<textElement>
						<font fontName="Arial Narrow" size="12" isBold="true" isPdfEmbedded="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA["Lieferdatum: "]]></textFieldExpression>
				</textField>
			</band>
		</groupHeader>
	</group>
	<group name="item" keepTogether="true">
		<groupExpression><![CDATA[$F{number}]]></groupExpression>
		<groupHeader>
			<band height="18">
				<textField>
					<reportElement x="0" y="1" width="78" height="15"/>
					<textElement verticalAlignment="Middle">
						<font fontName="Arial Narrow" isBold="true" isPdfEmbedded="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{REPORT_COUNT} + 1 + ".) " + $F{number}]]></textFieldExpression>
				</textField>
				<textField>
					<reportElement x="87" y="1" width="158" height="15"/>
					<textElement verticalAlignment="Middle">
						<font fontName="Arial Narrow" isPdfEmbedded="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{text1}]]></textFieldExpression>
				</textField>
				<textField isBlankWhenNull="true">
					<reportElement x="250" y="1" width="25" height="15" isPrintWhenDetailOverflows="true"/>
					<textElement textAlignment="Right" verticalAlignment="Middle">
						<font fontName="Arial Narrow" isPdfEmbedded="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{quantity}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true" isBlankWhenNull="true">
					<reportElement x="317" y="1" width="74" height="15" isPrintWhenDetailOverflows="true"/>
					<textElement textAlignment="Right" verticalAlignment="Middle">
						<font fontName="Arial Narrow" isPdfEmbedded="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{price} + " " + $P{CurrencySymbol} + "/" + $F{base}]]></textFieldExpression>
				</textField>
				<textField isBlankWhenNull="true">
					<reportElement x="397" y="1" width="58" height="15"/>
					<textElement textAlignment="Right" verticalAlignment="Middle">
						<font fontName="Arial Narrow" isPdfEmbedded="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{itemNetto} + " " + $P{CurrencySymbol}]]></textFieldExpression>
				</textField>
				<textField>
					<reportElement x="283" y="1" width="25" height="15" isPrintWhenDetailOverflows="true"/>
					<textElement verticalAlignment="Middle">
						<font fontName="Arial Narrow" isPdfEmbedded="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{unit}]]></textFieldExpression>
				</textField>
			</band>
		</groupHeader>
		<groupFooter>
			<band/>
		</groupFooter>
	</group>
	<title>
		<band height="110" splitType="Stretch">
			<image>
				<reportElement x="377" y="0" width="78" height="39"/>
				<imageExpression class="java.lang.String"><![CDATA[$P{PicturePath}]]></imageExpression>
			</image>
			<staticText>
				<reportElement style="Heading 1" x="0" y="0" width="349" height="23">
					<printWhenExpression><![CDATA[$P{UdId}.equals("14c348af7332cf5f708b9f8a758252fce0dc84c2") ? false : true]]></printWhenExpression>
				</reportElement>
				<textElement>
					<font fontName="Arial Narrow" isUnderline="true" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Bestellbestätigung]]></text>
			</staticText>
			<textField>
				<reportElement style="Heading 4" x="0" y="57" width="455" height="15"/>
				<textElement>
					<font fontName="Arial Narrow" isBold="false" isItalic="false" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Erfasst durch: " + $F{userName}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement style="Heading 4" x="0" y="39" width="455" height="18"/>
				<textElement>
					<font fontName="Arial Narrow" isItalic="false" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Bestellnummer: " + $F{orderNo}]]></textFieldExpression>
			</textField>
			<componentElement>
				<reportElement mode="Transparent" x="0" y="77" width="455" height="33" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"/>
				<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components <a href="http://jasperreports.sourceforge.net/xsd/components.xsd"" target="_blank">http://jasperreports.sourceforge.net/xsd/components.xsd"</a> printOrder="Vertical">
					<datasetRun subDataset="Company">
						<dataSourceExpression><![CDATA[$V{XmlDataSource}.dataSource("/PDFRequest/OrderData/BusinessPartner/Company")]]></dataSourceExpression>
					</datasetRun>
					<jr:listContents height="33" width="455">
						<textField isStretchWithOverflow="true">
							<reportElement positionType="Float" x="0" y="0" width="455" height="15" isPrintWhenDetailOverflows="true"/>
							<textElement>
								<font fontName="Arial Narrow" isBold="true" isPdfEmbedded="true"/>
							</textElement>
							<textFieldExpression class="java.lang.String"><![CDATA[$V{businessRelationString} + $F{name}]]></textFieldExpression>
						</textField>
						<textField isStretchWithOverflow="true">
							<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="16" width="455" height="15"/>
							<textElement>
								<font fontName="Arial Narrow" isPdfEmbedded="true"/>
							</textElement>
							<textFieldExpression class="java.lang.String"><![CDATA[$F{street} + ", " + $F{postalCode} + ", " + $F{city} + ", " + $F{country}]]></textFieldExpression>
						</textField>
					</jr:listContents>
				</jr:list>
			</componentElement>
		</band>
	</title>
	<columnHeader>
		<band height="15" splitType="Stretch">
			<staticText>
				<reportElement x="317" y="0" width="74" height="15" isPrintWhenDetailOverflows="true"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isBold="true" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Preis/Einheit]]></text>
			</staticText>
			<staticText>
				<reportElement x="397" y="0" width="58" height="15"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isBold="true" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Summe]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="128" splitType="Stretch">
			<printWhenExpression><![CDATA[$V{isVariant}]]></printWhenExpression>
			<crosstab ignoreWidth="false">
				<reportElement x="0" y="0" width="455" height="125" isPrintInFirstWholeBand="true"/>
				<crosstabParameter name="CurrencySymbol">
					<parameterValueExpression><![CDATA[$P{CurrencySymbol}]]></parameterValueExpression>
				</crosstabParameter>
				<crosstabParameter name="Base">
					<parameterValueExpression><![CDATA[$F{base}]]></parameterValueExpression>
				</crosstabParameter>
				<crosstabParameter name="Unit">
					<parameterValueExpression><![CDATA[$F{unit}]]></parameterValueExpression>
				</crosstabParameter>
				<crosstabDataset isDataPreSorted="true">
					<dataset>
						<datasetRun subDataset="ItemVariant">
							<dataSourceExpression><![CDATA[$V{ItemVariantSource}]]></dataSourceExpression>
						</datasetRun>
					</dataset>
				</crosstabDataset>
				<crosstabHeaderCell>
					<cellContents/>
				</crosstabHeaderCell>
				<rowGroup name="variantRow" width="42">
					<bucket>
						<bucketExpression class="java.lang.String"><![CDATA[$F{variantRow}]]></bucketExpression>
					</bucket>
					<crosstabRowHeader>
						<cellContents backcolor="#F0F8FF" mode="Opaque">
							<box>
								<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
							</box>
							<textField>
								<reportElement style="Crosstab Data Text" stretchType="RelativeToTallestObject" x="0" y="0" width="42" height="25"/>
								<textElement verticalAlignment="Middle">
									<font fontName="Serif"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$V{variantRow}]]></textFieldExpression>
							</textField>
						</cellContents>
					</crosstabRowHeader>
					<crosstabTotalRowHeader>
						<cellContents backcolor="#BFE1FF" mode="Opaque">
							<box>
								<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
							</box>
							<textField>
								<reportElement style="Crosstab Data Text" stretchType="RelativeToTallestObject" x="0" y="0" width="42" height="25"/>
								<textElement verticalAlignment="Middle"/>
								<textFieldExpression class="java.lang.String"><![CDATA["Summe: "]]></textFieldExpression>
							</textField>
						</cellContents>
					</crosstabTotalRowHeader>
				</rowGroup>
				<columnGroup name="variantText" height="29" totalPosition="End">
					<bucket>
						<bucketExpression class="java.lang.String"><![CDATA[$F{variantText}]]></bucketExpression>
					</bucket>
					<crosstabColumnHeader>
						<cellContents backcolor="#F0F8FF" mode="Opaque">
							<box>
								<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
							</box>
							<textField isStretchWithOverflow="true">
								<reportElement style="Crosstab Data Text" stretchType="RelativeToTallestObject" x="0" y="0" width="39" height="29"/>
								<textElement verticalAlignment="Middle">
									<font fontName="Serif"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$V{variantText}]]></textFieldExpression>
							</textField>
						</cellContents>
					</crosstabColumnHeader>
					<crosstabTotalColumnHeader>
						<cellContents backcolor="#BFE1FF" mode="Opaque">
							<box>
								<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
							</box>
							<elementGroup>
								<textField isStretchWithOverflow="true">
									<reportElement style="Crosstab Data Text" x="94" y="0" width="47" height="29"/>
									<box>
										<leftPen lineWidth="0.5"/>
									</box>
									<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
										<font fontName="Serif" size="10" isBold="true"/>
									</textElement>
									<textFieldExpression class="java.lang.String"><![CDATA["Summe " + "(" + $P{CurrencySymbol} + ")"]]></textFieldExpression>
								</textField>
								<textField isStretchWithOverflow="true">
									<reportElement style="Crosstab Data Text" x="47" y="0" width="47" height="29"/>
									<box>
										<leftPen lineWidth="0.5"/>
									</box>
									<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
										<font fontName="Serif" size="10" isBold="true"/>
									</textElement>
									<textFieldExpression class="java.lang.String"><![CDATA["Preis " + "(" + $P{Base} + ")"]]></textFieldExpression>
								</textField>
								<textField isStretchWithOverflow="true">
									<reportElement style="Crosstab Data Text" x="0" y="0" width="47" height="29"/>
									<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
										<font fontName="Serif" size="10" isBold="true"/>
									</textElement>
									<textFieldExpression class="java.lang.String"><![CDATA["Menge " + "(" + $P{Unit} + ")"]]></textFieldExpression>
								</textField>
							</elementGroup>
						</cellContents>
					</crosstabTotalColumnHeader>
				</columnGroup>
				<measure name="quantityMeasure" class="java.lang.String">
					<measureExpression><![CDATA[$F{quantity}]]></measureExpression>
				</measure>
				<measure name="sumRowTotal" class="java.lang.String">
					<measureExpression><![CDATA[$F{sum1}]]></measureExpression>
				</measure>
				<measure name="quantityRowTotal" class="java.lang.Object">
					<measureExpression><![CDATA[$F{quantityRow}]]></measureExpression>
				</measure>
				<measure name="priceRowTotal" class="java.lang.Object">
					<measureExpression><![CDATA[$F{trolleygroup_price}]]></measureExpression>
				</measure>
				<measure name="sumItemTotal" class="java.lang.Double" calculation="Count">
					<measureExpression><![CDATA[java.lang.Double.parseDouble($F{sum1})]]></measureExpression>
				</measure>
				<measure name="quantityItemTotal" class="java.lang.String">
					<measureExpression><![CDATA[$F{quantity}]]></measureExpression>
				</measure>
				<crosstabCell width="39" height="25">
					<cellContents>
						<box>
							<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
						</box>
						<textField isStretchWithOverflow="true">
							<reportElement style="Crosstab Data Text" stretchType="RelativeToTallestObject" x="0" y="0" width="39" height="25"/>
							<textElement verticalAlignment="Middle">
								<font fontName="Serif"/>
							</textElement>
							<textFieldExpression class="java.lang.String"><![CDATA[$V{quantityMeasure}]]></textFieldExpression>
						</textField>
					</cellContents>
				</crosstabCell>
				<crosstabCell width="143" height="25" columnTotalGroup="variantText">
					<cellContents backcolor="#BFE1FF" mode="Opaque">
						<box>
							<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
						</box>
						<elementGroup>
							<textField>
								<reportElement style="Crosstab Data Text" x="47" y="0" width="47" height="24"/>
								<box rightPadding="1">
									<leftPen lineWidth="0.5"/>
								</box>
								<textElement textAlignment="Right" verticalAlignment="Middle">
									<font fontName="Serif" size="10"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$V{priceRowTotal}]]></textFieldExpression>
							</textField>
							<textField>
								<reportElement style="Crosstab Data Text" x="0" y="0" width="47" height="24"/>
								<box rightPadding="1"/>
								<textElement textAlignment="Right" verticalAlignment="Middle">
									<font fontName="Serif" size="10"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$V{quantityRowTotal}]]></textFieldExpression>
							</textField>
							<textField>
								<reportElement style="Crosstab Data Text" x="94" y="0" width="47" height="24"/>
								<box rightPadding="1">
									<leftPen lineWidth="0.5"/>
								</box>
								<textElement textAlignment="Right" verticalAlignment="Middle">
									<font fontName="Serif" size="10"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$V{sumRowTotal}]]></textFieldExpression>
							</textField>
						</elementGroup>
					</cellContents>
				</crosstabCell>
				<crosstabCell width="39" height="25" rowTotalGroup="variantRow">
					<cellContents>
						<box>
							<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
						</box>
						<textField isStretchWithOverflow="true">
							<reportElement style="Crosstab Data Text" stretchType="RelativeToTallestObject" x="0" y="0" width="39" height="25"/>
							<textElement verticalAlignment="Middle"/>
							<textFieldExpression class="java.lang.String"><![CDATA["" + $V{quantityItemTotal}]]></textFieldExpression>
						</textField>
					</cellContents>
				</crosstabCell>
			</crosstab>
		</band>
	</detail>
	<pageFooter>
		<band height="19" splitType="Prevent">
			<textField>
				<reportElement x="363" y="0" width="92" height="19"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isItalic="true" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<summary>
		<band height="161" splitType="Stretch">
			<textField isStretchWithOverflow="true">
				<reportElement x="366" y="1" width="89" height="19" isPrintWhenDetailOverflows="true"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Summe: " + $F{OrderAbs} + " " + $P{CurrencySymbol}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="349" y="21" width="106" height="19" isPrintWhenDetailOverflows="true"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["- Rabatt: " + $F{OrderDiscount} + " %"]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement stretchType="RelativeToTallestObject" x="160" y="0" width="90" height="19"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Gesamtmenge: "]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="250" y="0" width="25" height="19" isPrintWhenDetailOverflows="true"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{OrderQuanitity}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement positionType="Float" x="352" y="41" width="103" height="1" isPrintWhenDetailOverflows="true"/>
			</line>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="363" y="42" width="92" height="19" isPrintWhenDetailOverflows="true"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Netto: " + $F{OrderNetto} + " " + $P{CurrencySymbol}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="354" y="62" width="101" height="19" isPrintWhenDetailOverflows="true"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["+ MwSt: " + $F{vatRate} + " %"]]></textFieldExpression>
			</textField>
			<line>
				<reportElement positionType="Float" x="352" y="82" width="103" height="1" isPrintWhenDetailOverflows="true"/>
			</line>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="358" y="82" width="97" height="19" isPrintWhenDetailOverflows="true"/>
				<textElement textAlignment="Right">
					<font fontName="Arial Narrow" isBold="true" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Brutto: " + $F{brutto} + " " + $P{CurrencySymbol}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" pattern="">
				<reportElement x="0" y="131" width="455" height="15" isPrintWhenDetailOverflows="true">
					<printWhenExpression><![CDATA[$V{OrderDeliveryTerms} != null]]></printWhenExpression>
				</reportElement>
				<textElement verticalAlignment="Top">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Zustellart: " + $V{OrderDeliveryTerms}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="0" y="146" width="42" height="15" isPrintWhenDetailOverflows="true"/>
				<textElement verticalAlignment="Top" markup="none">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Sonstiges: ]]></text>
			</staticText>
			<textField>
				<reportElement x="0" y="116" width="455" height="15" isPrintWhenDetailOverflows="true">
					<printWhenExpression><![CDATA[$V{OrderDeliveryMethod} != null]]></printWhenExpression>
				</reportElement>
				<textElement>
					<font fontName="Arial Narrow"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Lieferung: " + $V{OrderDeliveryMethod}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement stretchType="RelativeToBandHeight" x="42" y="146" width="413" height="15">
					<printWhenExpression><![CDATA[$F{OrderDescription} != null]]></printWhenExpression>
				</reportElement>
				<textElement verticalAlignment="Top">
					<font fontName="Arial Narrow" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{OrderDescription}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="0" y="101" width="455" height="15">
					<printWhenExpression><![CDATA[$V{OrderPaymentTerms} != null]]></printWhenExpression>
				</reportElement>
				<textElement>
					<font fontName="Arial Narrow"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Zahlungsbedingungen: " + $V{OrderPaymentTerms}]]></textFieldExpression>
			</textField>
			<textField pattern="EEEEE dd MMMMM yyyy">
				<reportElement x="78" y="42" width="100" height="20"/>
				<textElement/>
				<textFieldExpression class="java.util.Date"><![CDATA[$F{deliveryDate}]]></textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>

at my JRXMLDatsource I setted the source format patterns like this

JRXmlDataSource reportSource = new JRXmlDataSource(document, headRecordPath);
reportSource.setDatePattern("mm.dd.yy");
reportSource.setNumberPattern("####0.00");

and of course handing over a instance of my FormatFactory

reportParams.put(JRParameter.REPORT_FORMAT_FACTORY, new InvoicePrintFormatFactory());

Everything works fine here if the datasource xml do not contain "" values for a date field. But if that happens I got the exception

org.apache.commons.beanutils.ConversionException: Unparseable date: ""
        at org.apache.commons.beanutils.locale.BaseLocaleConverter.convert(BaseLocaleConverter.java:241)
        at org.apache.commons.beanutils.locale.LocaleConvertUtilsBean.convert(LocaleConvertUtilsBean.java:285)
        at net.sf.jasperreports.engine.data.JRAbstractTextDataSource.convertStringValue(JRAbstractTextDataSource.java:69)
        at net.sf.jasperreports.engine.data.JRXmlDataSource.getFieldValue(JRXmlDataSource.java:313)
        at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:821)
        at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:785)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1482)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:126)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:864)
        at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
        at com.lmobile.crm.invoicePrinter.operator.Printer.operate(Printer.java:219)
        at com.lmobile.crm.invoicePrinter.service.InvoicePrintService.CreatePrintOrder(InvoicePrintService.java:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at za.co.softco.rest.ReflectionService.handle(ReflectionService.java:253)
        at za.co.softco.rest.ReflectionHandler.handle(ReflectionHandler.java:94)
        at za.co.softco.rest.RestWorker.handlePost(RestWorker.java:477)
        at za.co.softco.rest.RestWorker.handleClient(RestWorker.java:289)
        at za.co.softco.rest.RestWorker.run(RestWorker.java:152)
        at java.lang.Thread.run(Thread.java:680)
Caused by: java.text.ParseException: Unparseable date: ""
        at java.text.DateFormat.parse(DateFormat.java:337)
        at net.sf.jasperreports.engine.util.JRDateLocaleConverter.parse(JRDateLocaleConverter.java:84)
        at org.apache.commons.beanutils.locale.BaseLocaleConverter.convert(BaseLocaleConverter.java:230)
        ... 23 more

If I debug the method calls for my custom FormatFactory implementation I recognize that both methods are not being called until running on the exception. Thus I assume that jasper is using the default FormatFactory by any reason.

What do I wrong here? Do somebody have an idea about that?

Thanks in advance

m_hammel's picture
Joined: Jul 14 2010 - 7:16am
Last seen: 8 years 5 months ago

0 Answers:

No answers yet
Feedback