Create report without SQL datasource

0

All,
I was wondering if anybody could point me in the right direction for creating a report without the use of a SQL datasource.  I am building a webapp with a Java middle tier with the following code handling the service call:

            URL t = this.getClass().getResource("/testreport.jrxml");//locally stored .jrxml template right now
            jasperReport = JasperCompileManager.compileReport(t.getFile());
            String flatJSON = "{\"Customers\": [{\"ContactName\":\"John Doe\"},{\"ContactName\": \"Jane Smith\"}]}";
            iStream = new ByteArrayInputStream(flatJSON.getBytes());
            jsonDataSource = new JsonDataSource(iStream);
            jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), jsonDataSource);
            String dest = "C:\\test.pdf";
            JasperExportManager.exportReportToPdfFile(jasperPrint,dest);

The main problem I'm having is actually populating data in the report. I would like to be able to create a JSON on-the-fly and pass it into the report. What is the best approach without using an SQL connection? All the demos I find do not focus on a non-SQL approach. I would like to feed in a more complex JSON data object, but from what I've seen jasper is a little buggy with handling more complex JSON objects. I followed the jsondatasource example that comes with iReport, but I am unable to reproduce the data retreival in my example. 

I am using iReport writer 5.0.1. I tried setting up a new Connection/Datasource pointing to a local file, giving it a Datasource Type of "JSON Datasource", but to no avail. I also tried manually putting in the field name (Field Name= ContactName, field type = java.lang.Stinrg, Description = ContactName)...nothing.The Report query is set to "Customers" (without quotes) and a Query langauge of JSON. I am able to compile this report, too, so that is not the problem. The problem just seems to be reading the data into the report and seeing it reflected in the outgoing PDF.

Here Attached is the compile code from iReport:

Thanks so much in advance for the help!

[EDIT] - I'm attaching the source code. The editor doesn't seem to want to render the .jrxml code

Attachments: 
rsteier's picture
Joined: Feb 25 2013 - 11:49am
Last seen: 5 years 11 months ago

0 Answers:

No answers yet
Feedback