nicholas
nicholas

Reputation: 2772

Create Report Template with JRDataSource using Spring Custom Data Source

I have follow the tutorial from http://krams915.blogspot.com/2010/12/spring-3-mvc-jasper-integration.html to create a jasper report. Now, I need to create a template with Spring JRData Source.

What is the Factory class for Spring custom JRData Source ?

What is the static method to retrieve JRData Source ?

How to do it ?

Upvotes: 2

Views: 2029

Answers (2)

Arturo Volpe
Arturo Volpe

Reputation: 3627

Use a JRBeanCollectionDataSource, is really easy to use, just create a new instance with a List of objects, the objects of your report.

List<Object> reportItems = getReportItems();
JRDataSource datasource = new JRBeanCollectionDataSource(reportItems);

Please see this source code, is a implementation of a JRDataSource, is a really simple interface. The main method is getFieldValue, this method receive a JRField, (this is another simple class that have the field name) and return a Object, the toString() is the string printed in the report.

Sorry for my bad english

Cheers

Upvotes: 1

luksmir
luksmir

Reputation: 3154

In this case JRData Source is just a wrapper of a DAO class that is designed later in this tutorial (see SalesDAO). This class returns a list of sales objects (see Sales class for the full definition) which are constitute the Spring JRData Source.

You do not have to create any factory class / static method to access this data.

Upvotes: 2

Related Questions