spahrep Posted September 14, 2006 Share Posted September 14, 2006 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 valuesPost edited by: spahrep, at: 2006/09/13 17:12 Link to comment Share on other sites More sharing options...
lucianc Posted September 14, 2006 Share Posted September 14, 2006 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 Link to comment Share on other sites More sharing options...
spahrep Posted September 14, 2006 Author Share Posted September 14, 2006 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 More sharing options...
lucianc Posted September 14, 2006 Share Posted September 14, 2006 I don't see a query in your JRXML, but you pass a connection to the fillReport() method. This doesn't make sense. Where should the report data come from? Link to comment Share on other sites More sharing options...
spahrep Posted September 14, 2006 Author Share Posted September 14, 2006 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 More sharing options...
lucianc Posted September 14, 2006 Share Posted September 14, 2006 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 More sharing options...
spahrep Posted September 14, 2006 Author Share Posted September 14, 2006 I just added the whenNoDataType="AllSectionsNoDetail" variable to the following url, and it worked properly (it wasnt working for me before either) . http://jasperreports.sourceforge.net/samples/FontsReport.jrxml Thanks for all your help, i think im finaly back on track :P Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now