Jump to content
Changes to the Jaspersoft community edition download ×

Filling Subreport Multiple Times


ktrinad

Recommended Posts

By: Brent - bwenson

Filling Subreport Multiple Times

2004-09-02 07:51

Holy Crap!!!

 

I spent three days trying to figure this out. I was trying to load and fill a master report which contained a subreport that gets filled multiple times in the master report. I was trying to load the reports from a JAR file. I sent the master and the subreport to the JasperManager as inputstreams. This works fine if the subreport is only filled once, if you need to fill it multiple times in the report, it will NOT WORK.

 

I finally tried setting the Subreport Expression to a JasperReport type and the Subreport parameter as a java.lang.object type and it worked!!!

 

This is just as an FYI to anyone trying this. Here's a snippet of how I load the reports in Java...

 

ClassLoader loader = getClass().getClassLoader() ;

InputStream input = loader.getResourceAsStream

( "reports/masterReport.jasper" ) ;

JasperReport report = JasperManager.loadReport( input ) ;

Map parameters = new HashMap() ;

InputStream subreportIS = loader.getResourceAsStream

( "reports/subreport.jasper" ) ;

JasperReport subreport = JasperManager.loadReport( subreportIS ) ;

parameters.put( "SUBREPORT", subreport ) ;

JasperPrint print = JasperManager.fillReport(

report, parameters, loginWindow.con ) ;

 

JasperViewer.viewReport( print, false ) ;

 

 

By: C-Box - c-box

RE: Filling Subreport Multiple Times

2004-09-07 23:05

Hi,

 

I also work with SubReports that are called multiple times... I works fine... I don't know what went wrong with your report(s).

 

I pass all the needed SubReports via parameter to the masterreport. From there I pass the whole parametermap to each subreport. The SubReportExpression is always JasperReport (what else, if you pass them to the masterreport via parameter?!?) and the datasource-expression is always a JRDataSource (so custom-datasources of mine, that are also passed via parameter).

 

So I don't know what the actual problem is/was? And where are you using a java.lang.object like you mentioned????

 

C-Box

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