Jump to content
Changes to the Jaspersoft community edition download ×

use of a same JRXmlDataSource in multi subreport


ladef

Recommended Posts

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.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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