Jump to content
JasperReports Library 7.0 is now available ×

Only exporting the <jasperPrint> tag...


spahrep

Recommended Posts

My Jasper reports are coming out as only the following. Regardless of what the report is, all that the xml file contains is as follows. Anyone know what I'm doing wrong?

***************************

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

<!DOCTYPE jasperPrint (View Source for full doctype...)>

<jasperPrint name="FontsReport" pageWidth="595" pageHeight="842" locale="en_US" timezone="America/Halifax" orientation="Portrait" />

******************************

The code:

JSP:

JasperPrint reportOutput = reportServer.generateReport(client,reportID);

HttpServletResponse responseObject;

responseObject = (HttpServletResponse)pageContext.getResponse();

responseObject.setHeader("Content-Disposition", "attachment; filename="report.xml"");

responseObject.setHeader("Content-Description", "report.xml");

String contentType = getServletContext().getMimeType("report.xml");

responseObject.setContentType(contentType);

 

OutputStream output = responseObject.getOutputStream();

System.out.println("Generating Report...");

JasperExportManager.exportReportToXmlStream(reportOutput,output);

 

**************************

 

Java:

public JasperPrint generateReport(ServiceClient client, Integer reportID) throws ServiceException

{

...

System.out.println("XML from DB: "+ report.getField("DynamicReportXML"));

StringBufferInputStream stringReader = new StringBufferInputStream((String)report.getField("DynamicReportXML"));

JasperDesign design = JRXmlLoader.load(stringReader);

JasperReport compiledReport = JasperCompileManager.compileReport(design);

JasperPrint jasperPrint = JasperFillManager.fillReport( compiledReport, new HashMap(), dbConnection.getConnection());

return jasperPrint;

….

 

 

*** Edit**

The reports have no parameters other then static values

Post edited by: spahrep, at: 2006/09/13 17:12

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

lucianc wrote:

It seems that the report you generate is empty. Can you verify whether the report query returns something? You could also try setting whenNoDataType="AllSectionsNoDetail" for the report.

HTH,
Lucian

 

The report query does return the reports. I just added the variable you suggested, here is an example report:

**********************

<?xml version="1.0"?> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <!--the root tag element-->

<jasperReport name="Hello55_Report" whenNoDataType="AllSectionsNoDetail">

<detail>

<band height="30">

<staticText> <reportElement x="180" y="0" width="200" height="20"/>

<text><![CDATA[Hello World!]]></text>

</staticText>

</band>

</detail>

</jasperReport>

********************

 

This now yeilds:

*******************

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

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

 

<jasperPrint name="Hello55_Report" pageWidth="595" pageHeight="842" locale="en_US" timezone="America/Halifax">

<page/>

</jasperPrint>

****************

Is there something wrong with this report format? This is the simplest version of a report i could think of to make.

Link to comment
Share on other sites

I was following an example that i found online that used some variables.Eventualy i will be hooking it up for parameters, not just static reports, but wanted to try and get this working one step at a time.

 

The hashMap being passed is empty, so i didnt think it was having any ill effects, just returning a JasperPrint out of the jasper report. Is this the cause, and if so is there a simple way to go from JasperReport to JasperPrint w/o filling?

Link to comment
Share on other sites

If you want to test some static report output, you should put some content (texts, etc) in the title or summary report sections. You only have the detail section, and the details section corresponds to rows in the report's data source (and you don't feed any data to the report).

 

HTH,

Lucian

Link to comment
Share on other sites

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...