Jump to content
Changes to the Jaspersoft community edition download ×

null xml datasource in muliple subreports


cultfigure

Recommended Posts

I've been battling with this for a couple of days now and thought I'd solicit the help of some experts...

 

I've got the following:

 

Code:

// Create the xml data source
JRXmlDataSource xml = new JRXmlDataSource(xmlStream, "/companies/store"«»);
MyJasperHelper jhelper = new MyJasperHelper(xml);
map.put("xml_data", jhelper);

// Fill the report *******************************************************
jasperPrint = JasperFillManager.fillReport(
this.getClass().getResourceAsStream(reportsDir + "CoReport.jasper"«»), map, jhelper.getDataSource());

 

...with JasperHelper:

Code:
[code]
public class MyJasperHelper {

private JRXmlDataSource data;

public MyJasperHelper(JRXmlDataSource mydata) {
setData(mydata);
}

public JRXmlDataSource getDataSource() {
try {
this.data.moveFirst();
JRXmlDataSource d = this.data.dataSource("/companies/store"«»);
return d;
} catch (JRException e) {
// e.printStackTrace();
}
return data;
}

public void setData(JRXmlDataSource data) {
this.data = data;
}

}

 

Now, in my report, I have 3 sub-reports that refer to the $P{xml_data}.getDataSource() and everything seems to work out fine as the report does access the getDataSource fx() correctly each time a subreport loads... however, only the first report loads, as though the detail record is being used once and not being rewound -- ala moveFirst() -- as it should.

 

Does anyone have any suggestions on what I may be doing wrong? Any help would greatly be appreciated!

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

...so I've created two reports and my Helper works when rewinding on the second report, though it still doesn't print the sub-reports after the first one.

 

I figure this has something to do with the fact that the data is being used on one report and I cannot figure out why the data is not being rewound (via moveFirst())!?

 

If I can't figure this out soon, I think I'll file a bug report because as far as I can tell the JRXmlDataSource is correct, but not being used properly by jasper reports.

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