Jump to content
We've recently updated our Privacy Statement, available here ×

field not displaying in generated report


koolkhel

Recommended Posts

I'm trying to generate report by hand (not by iReport).

I have following code:

try {
            Map parameters = new HashMap();
            parameters.put("HIBERNATE_SESSION", sessionManager.getSession());
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            File sourceFile = new File(waybillPaymentJRXML.getResource().toURL().toURI());
            File compiledFile = new File(JRProperties.getProperty(JRProperties.COMPILER_TEMP_DIR) + "/" +
                    sourceFile.getName() + ".jasper");
            JasperCompileManager.compileReportToFile(sourceFile.getPath(), compiledFile.getPath());
            JasperReport report = (JasperReport) JRLoader.loadObject(compiledFile);
            JasperPrint actualJasperPrint = JasperFillManager.fillReport(report, parameters);

            JRAbstractExporter exporter = new JROdtExporter();
            exporter.setParameter(JRExporterParameter.JASPER_PRINT, actualJasperPrint);
            exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
            exporter.exportReport();
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            return StreamResponseFactory.getStreamResponse(ResponseType.ODT, bais);
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }

where "waybillPaymentJRXML" is jrxml file with report design. I have it attached.

The report has following HQL query:

select sum(waybill.passengersTransported * 10) as summary,
    waybill.driver.name as driverName
from Waybill as waybill
group by waybill.driver.name

fields are:

<field name="summary" class="java.lang.Long">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="driverName" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>

And when I try to generate this report by this code the column with field "summary" has _no_ data.

<textField>
                <reportElement x="284" y="0" width="124" height="26"/>
                <textElement>
                    <font fontName="SansSerif" size="12"/>
                </textElement>
                <textFieldExpression class="java.lang.Long"><![CDATA[$F{summary}]]></textFieldExpression>
            </textField>

while adjanced filed with driverName is ok.

How do I cope with it?

iReport 3.7.1 use jasperreports 3.7.1 but in my project this jasperreports version generates just column headers (i have no idea why), so I use jasperreports 3.5.3 -- it does everything ok but that missing column data. preview in iReport is absolutely ok.

nothing interesting through log4j.category.net.sf.jasperreports=debug



Post Edited by koolkhel at 02/20/2010 12:40
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...