Jump to content
Changes to the Jaspersoft community edition download ×

Create report without SQL datasource


rsteier

Recommended Posts

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);[/code]

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

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