Jump to content
Changes to the Jaspersoft community edition download ×

JRMapCollectionDataSource for subreport


Recommended Posts

By: jasperkan - jasperkannan

JRMapCollectionDataSource for subreport

2006-01-17 13:31

Hi

 

i have a main report which executes a database procedure and gets the resultset and show the data. I would need to process the data and show the summary data in a subreport. For this i m using scriplet class and it store the processed data in a JRMapCollectionDataSource and passed to the summary data subreport .Everything works fine without giving an error but the subreport is not getting filled .

 

I would be grateful for any pointers or a better way to do this with out calling the proc twice.

 

 

 

 

By: Neil Lamka - neil_lamka

RE: JRMapCollectionDataSource for subreport

2006-08-09 18:20

Did you ever get an answer to this post?

 

I'm trying to do the same thing but having problems (since I'm not a java guy) figuring out exactly how to set things up.

 

What I tried was to define a variable in the main report of type net.sf.jasperreports.engine.data.JRMapCollectionDataSource

 

I then thought I needed to "new" one of those so I put

 

new net.sf.jasperreports.engine.data.JRMapCollectionDataSource()

 

in the variable Initial value expression but that generates an error saying that the constructor is undefined. That was obviously wrong.

 

I then tried to get the variable in my scriptlet by adding

 

net.sf.jasperreports.engine.data.JRMapCollectionDataSource src = (net.sf.jasperreports.engine.data.JRMapCollectionDataSource)getVariableValue("combinedDataSource");

 

and that generates the following error.

C:Documents and SettingsNeil Lamka.ireportScheduleExpressGenericReportsGenericDailyReportScriptlet.java:98: unreported exception net.sf.jasperreports.engine.JRScriptletException; must be caught or declared to be thrown (net.sf.jasperreports.engine.data.JRMapCollectionDataSource)getVariableValue("combinedDataSource");

 

So at this point, I'm looking for an example or some other way to get this setup.

 

Hope you can help.

Neil

 

 

By: Lucian Chirita - lucianc

RE: JRMapCollectionDataSource for subreport

2006-08-10 02:25

You can see examples of scriptlets collecting data in the scriptlet and tableofcontents samples in the JR distribution. However, you should be aware that writing a Java class (and a scriptlet is a Java class) obviously requires basic Java knowledge.

 

A solution for you would consist of the following:

- a system variable "SubreportData" of type java.util.List initialized with new java.util.ArrayList()

- a scriptlet which in one of its methods gets the SubreportData value and adds to it a java.util.Map of values for the subreport

- a subreport in the summary band having new JRMapCollectionDataSource($V{SubreportData}) as data source expression.

 

Also note that the JR forums have moved here

http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=showcat&catid=8

 

HTH,

Lucian

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