• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Struts 2.2 jasper report writing null data

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using tje jasper reports plugin with Struts 2.2.3. We have developed 3 reports and 2 of them are working correctly. For our last report, even though valid data is being passed to the report, all the data is printing out null. Here is a snippet from the .jrxml file. I've removed alot of fields, but the meat is consistent:

<?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="OperationStatisticsRpt" pageWidth="1440" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="1400" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<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>
<subDataset name="Table Dataset 1"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="aBoxFlag" class="java.lang.String">
<fieldDescription><![CDATA[aBoxFlag]]></fieldDescription>
</field>
<field name="aEquivAvailFac" class="java.math.BigDecimal">
<fieldDescription><![CDATA[aEquivAvailFac]]></fieldDescription>
</field>
<field name="class" class="java.lang.Class">
<fieldDescription><![CDATA[class]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement x="472" y="18" width="240" height="20"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Operational Statistics]]></text>
</staticText>
<image>
<reportElement x="4" y="0" width="119" height="79"/>
<imageExpression><![CDATA[$P{jasperRptParams.IMAGE_LOGO}]]></imageExpression>
</image>
</band>
</title>
<columnHeader>
<band height="79" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="93" height="20"/>
<textElement/>
<text><![CDATA[aBoxFlag]]></text>
</staticText>
<staticText>
<reportElement x="186" y="0" width="93" height="20"/>
<textElement/>
<text><![CDATA[aEquivAvailFac]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="40">
<textField>
<reportElement x="0" y="0" width="93" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{aBoxFlag}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="186" y="0" width="93" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{aEquivAvailFac}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="54" splitType="Stretch"/>
</columnFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>

I'm using jasperreports-4.1.3 and all the equivalent necessary associated jars

Here is the following from the struts.xml file to show the config:

<struts>
<package name="default" namespace="/" extends="jasperreports-default">
<global-results>
<result name="pdf" type="jasper">
<param name="location">/reports/${jasperRpt}</param>
<param name="dataSource">jasperRptData</param>
<param name="format">PDF</param>
<param name="reportParameters">jasperRptParams</param>
<param name="documentName">jasperRptFileName</param>
</result>
<result name="xls" type="jasper">
<param name="location">/reports/${jasperRpt}</param>
<param name="dataSource">jasperRptData</param>
<param name="format">XLS</param>
<param name="documentName">jasperRptFileName</param>
<param name="reportParameters">jasperRptParams</param>
</result>
</global-results>


My action class contains all of the referenced param values the xls and pdf result type return. We have been able to run this report outside of struts and tomcat with no problem, from java code. It's when we use the report within tomcat with the jasper plugin that the null values are printed out, so there is something quirky about this report and the struts-2.2.3 jasper plugin.

Any help will be GREATLY appreciated
 
V. Oliver Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just noticed..ignore the fact that the imageExpression parameter is not declared. It's one of the attributes I stripped from the file
 
Ranch Hand
Posts: 129
Netbeans IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll better use a IDE such as Netbeans along with iReport plugin rather than writing the .jrxml myself.

 
V. Oliver Smith
Greenhorn
Posts: 11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitin,

Actually, we use iReports to generate the .jrxml. I only posted it because I thought the issue may be in it.

Come to find it, it was an Eclipse IDE issue and not a jasper reports issue at all. The detail data object that was passed to jasper had incorrect getter method names so every result was coming back null. Once we fixed the getter method names, everything worked fine
 
a wee bit from the empire
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!