Hello !!
I am with a problem on compiling my jasperDesign. Somebody could
help me. And sorry for my English ....
I am using JR1.1.1
My file jrxml is the follow
file: test.jrxml
------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report
Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="test" pageWidth="842" pageHeight="595"
orientation="Landscape" columnWidth="812" leftMargin="15"
rightMargin="15" topMargin="10" bottomMargin="10">
<style name="Arial_Normal" isDefault="true" fontName="Arial"
fontSize="8" isBold="false" isItalic="false" isUnderline="false"
isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252"
isPdfEmbedded="false"/>
<style name="Arial_Bold" isDefault="false" fontName="Arial"
fontSize="8" isBold="true" isItalic="false" isUnderline="false"
isStrikeThrough="false" pdfFontName="Helvetica-Bold"
pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<subDataset name="Defect_Machines">
<parameter name="idtDefect" class="java.lang.Integer"/>
<queryString><![CDATA[
select name, date from defect_machine dm, machine m where
dm.id_def=$P{idtDefect} and
dm.id_mach=m.id
]]></queryString>
<field name="date" class="java.util.Date"/>
<field name="name" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[SELECT DISTINCT desc as defect, id FROM defect]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="defect" class="java.lang.String"/>
<detail>
<band height="100">
<crosstab isRepeatColumnHeaders="false">
<reportElement x="0" y="20" width="812" height="80"
mode="Opaque"/>
<crosstabParameter name="def"
class="java.lang.String">
<parameterValueExpression>$F{defect}</parameterValueExpression>
</crosstabParameter>
<crosstabParameter name="idtDefect"
class="java.lang.String">
<parameterValueExpression>$F{id}</parameterValueExpression>
</crosstabParameter>
<crosstabDataset>
<dataset>
<datasetRun subDataset="Defect_Machines">
<datasetParameter name="idtDefect">
<datasetParameterExpression><![CDATA[$F{id}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
</dataset>
</crosstabDataset>
<rowGroup name="Defect" width="50"
totalPosition="End">
<bucket>
<bucketExpression
class="java.lang.String">$F{defect}</bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents>
<box leftBorder="2Point"
bottomBorder="2Point" rightBorder="2Point"/>
<textField>
<reportElement x="5" y="5" width="40"
height="20"/>
<textFieldExpression>$V{Defect}</textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents backcolor="#60FFFF">
<box leftBorder="2Point"
bottomBorder="2Point" rightBorder="2Point"/>
<staticText>
<reportElement x="5" y="5" width="45"
height="20"/>
<text>Total</text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="Month" height="30"
totalPosition="End" headerPosition="Stretch">
<bucket>
<bucketExpression
class="java.util.Date">$P{REPORT_SCRIPTLET}.truncateToMonth($F{date})</bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents>
<box topBorder="2Point"
bottomBorder="2Point" rightBorder="2Point"/>
<rectangle radius="10">
<reportElement x="4" y="4" width="52"
height="22"/>
<graphicElement pen="1Point"/>
</rectangle>
<textField pattern="MMM">
<reportElement x="5" y="5" width="50"
height="20"/>
<textElement textAlignment="Center"
verticalAlignment="Middle"/>
<textFieldExpression
class="java.util.Date">$V{Month}</textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents backcolor="#FFFF60">
<box topBorder="2Point"
bottomBorder="2Point" rightBorder="2Point"/>
<staticText>
<reportElement x="5" y="5" width="20"
height="15"/>
<text>Total</text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<columnGroup name="Machine" height="40"
totalPosition="End">
<bucket>
<bucketExpression
class="java.lang.String">$F{name}</bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents>
<box bottomBorder="2Point"
rightBorder="2Point"/>
<textField>
<reportElement x="5" y="5" width="20"
height="30"/>
<textFieldExpression
class="java.lang.String">$V{Machine}</textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents backcolor="#FFFFC0">
<box bottomBorder="2Point"
rightBorder="2Point"/>
<staticText>
<reportElement x="5" y="5" width="20"
height="30"/>
<text>TOTAL</text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="Count" class="java.lang.Integer"
calculation="Sum">
<measureExpression>$F{name}</measureExpression>
</measure>
<crosstabCell width="30" height="25">
<cellContents backcolor="#FFFFFF">
<box bottomBorder="1Point" rightBorder="1Point"/>
<textField>
<reportElement x="0" y="0" width="25"
height="25"/>
<textElement textAlignment="Right"
verticalAlignment="Middle"/>
<textFieldExpression
class="java.lang.Integer">$V{Count}</textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="30" height="25"
columnTotalGroup="Machine">
<cellContents backcolor="#FFFFC0">
<box bottomBorder="1Point" rightBorder="1Point"/>
<textField>
<reportElement x="0" y="0" width="25"
height="25" style="Arial_Bold"/>
<textElement textAlignment="Right"
verticalAlignment="Middle"/>
<textFieldExpression
class="java.lang.Integer">$V{Count}</textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="35" height="25"
columnTotalGroup="Month">
<cellContents backcolor="#FFFF60">
<box bottomBorder="1Point" rightBorder="1Point"/>
<textField>
<reportElement x="0" y="0" width="30"
height="25" style="Arial_Bold"/>
<textElement textAlignment="Right"
verticalAlignment="Middle"/>
<textFieldExpression
class="java.lang.Integer">$V{Count}</textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell height="30"
rowTotalGroup="Defect">
<cellContents backcolor="#60FFFF">
<box bottomBorder="1Point" rightBorder="1Point"/>
<textField>
<reportElement x="0" y="0" width="25"
height="30" style="Arial_Bold"/>
<textElement textAlignment="Right"
verticalAlignment="Middle"/>
<textFieldExpression
class="java.lang.Integer">$V{Count}</textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell rowTotalGroup="Defect"
columnTotalGroup="Machine">
<cellContents backcolor="#60FFC0">
<box bottomBorder="1Point" rightBorder="1Point"/>
<textField>
<reportElement x="0" y="0" width="25"
height="30" style="Arial_Bold"/>
<textElement textAlignment="Right"
verticalAlignment="Middle"/>
<textFieldExpression
class="java.lang.Integer">$V{Count}</textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell rowTotalGroup="Defect"
columnTotalGroup="Month">
<cellContents backcolor="#60FF60">
<box bottomBorder="1Point" rightBorder="1Point"/>
<textField>
<reportElement x="0" y="0" width="30"
height="30" style="Arial_Bold"/>
<textElement textAlignment="Right"
verticalAlignment="Middle"/>
<textFieldExpression
class="java.lang.Integer">$V{Count}</textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</detail>
</jasperReport>
---------------------------------------------------------------------------------------------
I
When I compiling show the message:
net.sf.jasperreports.engine.JRException: Report design not valid :
1. Field not found : defect
at
net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:267)
at
net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:144)
at
net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:131)
at
net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:211)
at
net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:197)
at report.Jasper.main(Jasper.java:54)
The tables and relations with I am using is:
defect(_id_, desc)
machine(_id_, name)
defect_machine(_id_, id_def, id_mach, date)
The layout to I want is:
--------------------------------------------------------------------------
Month1 | Month2
| ...
machine1| machine2 | Total | machine1 machineN
| ...
defect1 | | | |
defect2 | | | |
defectN |
Total