Jump to content
Changes to the Jaspersoft community edition download ×

Problem with JasperManager.fillReport()


Recommended Posts

By: Allen Pham - apham

Problem with JasperManager.fillReport()

2003-04-16 14:15

Hi,

 

I'm currently using iReport to create my report. Using iReport I am able to compile and see the report title in pdf format properly. However, when attempting to use the JaserReport API, it seems that the title some how disappears. Below is attached a Test xml file as well as the code to run it. Any advice will be greatly appreicated.

 

Java Source File

 

package focalpoint;

 

import java.awt.*;

import java.util.*;

import javax.swing.*;

import java.sql.*;

import dori.jasper.engine.*;

import dori.jasper.view.*;

 

class PrintReport {

 

public PrintReport(String compiledReport) {

try {

JasperPrint jasperPrint = JasperManager.fillReport(compiledReport, null, DBUtils.getConnection());

ReportViewer.viewReport(jasperPrint);

} catch (Exception ex) {

JOptionPane.showMessageDialog(null,

ex.getMessage(),

"ERROR",

JOptionPane.ERROR_MESSAGE);

}

}

 

public PrintReport(String compiledReport, Map param) {

try {

JasperPrint jasperPrint = JasperManager.fillReport(compiledReport, param, (JRDataSource) null);

ReportViewer.viewReport(jasperPrint);

} catch (Exception ex) {

JOptionPane.showMessageDialog(null,

ex.getMessage(),

"ERROR",

JOptionPane.ERROR_MESSAGE);

}

}

 

public static void main(String args[]) {

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

} catch (Exception ex) {

System.out.println(ex.getMessage());

}

 

 

Map parameters = new HashMap();

parameters.put("REPORT_TITLE", "BLAH");

 

new PrintReport("reports/Test.jasper", parameters);

 

}

}

 

XML FILE

 

<?xml version="1.0" encoding="UTF-8" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport

name="Test"

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="612"

pageHeight="792"

columnWidth="535"

columnSpacing="0"

leftMargin="30"

rightMargin="30"

topMargin="20"

bottomMargin="20"

whenNoDataType="BlankPage"

isTitleNewPage="false"

isSummaryNewPage="false">

<parameter name="REPORT_TITLE" isForPrompting="true" class="java.lang.String"/>

<title>

<band height="0">

</band>

</title>

<pageHeader>

<band height="50">

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="52"

y="3"

width="440"

height="38"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Center" verticalAlignment="Middle" lineSpacing="Single">

<font fontName="" pdfFontName="Helvetica-Bold" size="18" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">$F{REPORT_TITLE}</textFieldExpression>

</textField>

</band>

</pageHeader>

<columnHeader>

<band height="0">

</band>

</columnHeader>

<detail>

<band height="0">

</band>

</detail>

<columnFooter>

<band height="0">

</band>

</columnFooter>

<pageFooter>

<band height="0">

</band>

</pageFooter>

<summary>

<band height="0">

</band>

</summary>

</jasperReport>

Link to comment
Share on other sites

  • Replies 0
  • 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...