Project

General

Profile

Defect #777

using the same foundset for 2 subreports doesn't work

Added by Sanneke Aleman over 10 years ago. Updated about 10 years ago.

Status:
Resolved
Priority:
Normal
Start date:
01/10/2014
Due date:
% Done:

100%

Estimated time:
Browser (if web client):

Description

using the same foundset for 2 subreports doesn't work. First report will get a foundset second will not. See sample files. Made with the database example_data orders.


Files

orderdetails.jrxml (2.19 KB) orderdetails.jrxml Sanneke Aleman, 01/10/2014 03:52 PM
orderdetails_2.jrxml (2.19 KB) orderdetails_2.jrxml Sanneke Aleman, 01/10/2014 03:52 PM
orders.jrxml (3.3 KB) orders.jrxml Sanneke Aleman, 01/10/2014 03:52 PM
orders.jrxml (3.32 KB) orders.jrxml Sanneke Aleman, 02/04/2014 10:23 AM
orderdetails_2.jrxml (2.19 KB) orderdetails_2.jrxml Sanneke Aleman, 02/04/2014 10:23 AM
orderdetails.jrxml (2.55 KB) orderdetails.jrxml Sanneke Aleman, 02/04/2014 10:23 AM
orders.jrxml (3.75 KB) orders.jrxml Main report Andrei Costache, 02/08/2014 05:56 PM
orderdetails.jrxml (2.73 KB) orderdetails.jrxml First subreport Andrei Costache, 02/08/2014 05:56 PM
orderdetails_2.jrxml (2.49 KB) orderdetails_2.jrxml Second subreport Andrei Costache, 02/08/2014 05:56 PM

History

#2

Updated by Andrei Costache about 10 years ago

  • Status changed from New to In Progress
  • Assignee set to Andrei Costache

Hi Sanneke,

Have you tried the same scenario with the 4.x version of the plugin? What results do you get with that setup?

Regards,
Andrei

#3

Updated by Andrei Costache about 10 years ago

Hi Sanneke,

Using Servoy 7.x and the 4.x (trunk) version of the plugin everything works just fine.

Still, we are trying to have a look at this using the 3.x version but there is a problem, apparently, with the report files (iReport 4.0 cannot open them, seems they have been created with a newer version of iReport). What version of iReport have you used when creating/editing them? In case you have used a version higher than the recommended 4.0 (for the 3.x plugin), could you please export with iReport 4.x as well?

Best regards,
Andrei

#4

Updated by Sanneke Aleman about 10 years ago

I tested this with the 4 plugin and 7.3.1 We did update the plugin to jasper 5.5 but would that cause this problem?

#5

Updated by Andrei Costache about 10 years ago

Sanneke Aleman wrote:

I tested this with the 4 plugin and 7.3.1 We did update the plugin to jasper 5.5 but would that cause this problem?

What results did you get by testing with plugin version 4.x?
Also, you say you update to jasper 5.5: which base plugin version did you use to update with jasper 5.5? Did you get the foundset problem after the update to the jasper engine?

Regards,
Andrei

#6

Updated by Andrei Costache about 10 years ago

Just tried this with a simple 3.3.x and a Servoy 7.3.1 and both foundsets seem to get the data.
I suppose you are using a simple call to runreport, yes?

#7

Updated by Sanneke Aleman about 10 years ago

To be sure I tried with the plugin 4.0.0 Jasper 4.6 servoy 7.3.1. But I don't get any data in the the second subreport.

#8

Updated by Sanneke Aleman about 10 years ago

This is my call to the report:
plugins.jasperPluginRMI.runReport(foundset, 'orders.jrxml', null, plugins.jasperPluginRMI.OUTPUT_FORMAT.VIEW,null);

#9

Updated by Andrei Costache about 10 years ago

Managed to see this and also find the cause: filling a subreport exhausts the data source passed to it. Therefore we need to "rewind" the datasource for the following subreport.
Looking into finding the best way to do this.

#10

Updated by Andrei Costache about 10 years ago

Hi Sanneke,

As indicated, the exhausting of the datasource was the cause of the apparently empty foundset. The problem was the index of the foundset was at the "end", so no more "next()" data was available. This issue seems to be the way reports and subreports work with datasources, in Jasper Reports.

I have fixed the issue, in the 4.x version of the plugin. In a nutshell, I have added a helper method, to trigger/force the rewinding of the foundset, called com.servoy.plugins.jasperreports.JasperReportsResourceLoader.rewindServoyDataSource. This method has to be called on the subreport foundset.

I am detailing the fix now:
- first, in orders.xml (main report), the orders_to_order_details field has to declared of type com.servoy.plugins.jasperreports.AbstractServoyDataSource
- secondly, the second subreport has to be placed in a separate detail band; without this the datasource will not be rewinded
- thirdly, the datasource expression of the subreport must be wrapped inside the new method call; the new datasource expression needs to be this: <dataSourceExpression><![CDATA[com.servoy.plugins.jasperreports.JasperReportsResourceLoader.rewindServoyDataSource($F{orders_to_order_details})]]></dataSourceExpression>

What will happen is that when the second detail band is reached, the second subreport's datasource expression is evaluated and this will trigger a call to rewinding the foundset, this the second subreport will now have a "full" foundset to use.

I have added modified report files (please don't mind the coloring I added for fonts, it was just for testing purposes). Please have a look at these. The modifications are done mainly in the main report.

This was the easiest fix possible currently. We could have also tried to use Scriptlets, but this would be not very easy for unexperienced users of the plugin. The fix is inspired from what the creators of JasperReports offer as advice: http://community.jaspersoft.com/questions/514992/no-data-all-first-subreport.

Let me know if this works fine or if you encounter any problems.

Best regards,
Andrei

P.S. (Update) Please note that the orders_to_orders_details field is of type com.servoy.plugins.jasperreports.AbstractServoyDataSource, but should also work for other datasources which implement net.sf.jasperreports.engine.JRRewindableDataSource (if all imports are done correctly in the report, so the compilation will succeed). For current Servoy datasources, using the AbstractServoyDataSource will suffice.

Also available in: Atom PDF