use of a same JRXmlDataSource in multi subreport

0
I would like to create report with 2 subreports.
Each report use the same xml datasource.

My problem is that the second subreport is empty.
In fact, after the first subreport, the datasource position is to the end...
Do you know how i cant reset the position of the xml datasource to the begining (rewind) ?

Thank you for help.
ladef's picture
6
Joined: Oct 5 2006 - 11:02pm
Last seen: 13 years 12 months ago

3 Answers:

0
Hi,

I assume you have this xml :

<root>
<subelement>..</subelement>
<subelement>..</subelement>
</root>

and you want iterate through subelement elements in the main report, try this in the datasource expression :

choose "Use datasource expression" in combolist
and
type "((net.sf.jasperreports.engine.data.JRXmlDataSource)
$P{REPORT_DATA_SOURCE}).dataSource("/root/subelement")"
in the textfield.

This will reset the datasource in the subreport because it'll create a new one.

Hope this will help you.
homer's picture
5
Joined: Oct 2 2006 - 6:30am
Last seen: 14 years 1 day ago
0
Perhaps creating a new DataSource is not a good solution (performance of XML Datasources is anyway not the best)

As I don't work with XML DataSources but with CustomDataSources instead, I would suggest making your own method that returns the datasource with calling the "moveFirst" method before.

just my two cents
C-Box
C-Box's picture
2373
Joined: Jul 19 2006 - 5:58pm
Last seen: 1 month 4 days ago
0
Thank you.

I tried :
$P{REPORT_DATA_SOURCE}).dataSource("/root/subelement")
It's ok.

I will try (when possible) the second solution (moveFirst). It's a better solution when we work with lot of data.

:)
ladef's picture
6
Joined: Oct 5 2006 - 11:02pm
Last seen: 13 years 12 months ago
Feedback