Jump to content
We've recently updated our Privacy Statement, available here ×

multiple datasources


adamzrk

Recommended Posts

I have to use in my jrmxl template multiple JRBeanCollectionDataSources with different beans. Report will contain a few crosstabs. Can anyone tell me is this possible? Can I pass somehow multiple JRBeanCollectionDataSources to jrxml file and proceed it?

 

Regards

Adam

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

If you only intend to use each data source for a single crosstab, you can take the following approach:

  • create a subdataset corresponding to the data source

pass the JRBeanCollectionDataSource as a report parameter

connect the crosstab to the subdataset and use the JRBeanCollectionDataSource parameter as data source:

Code:

<crosstab>
<crosstabDataset>
<dataset>
<datasetRun subDataset="myCrosstabDataset">
<dataSourceExpression>$P{myCrosstabDataSource}</dataSourceExpression>
</datasetRun>
</dataset>
</crosstabDataset>
</crosstab>
[/ul]

 

HTH,

Lucian

Link to comment
Share on other sites

Thanks. When I use Your suggestion I used JRBeanCollectionDataSource as parameter I got exception:

 

15:01:22,380 ERROR [Digester] End event threw exception

java.lang.NoSuchMethodException: No such accessible method: setDataSourceExpression() on object: net.sf.jasperreports.crosstabs.design.JRDesignCrosstabDataset

at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:248)

at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:216)

Link to comment
Share on other sites

<crosstabDataset>

<dataset >

<datasetRun subDataset="globalVisitCountPerPageDS" />

<dataSourceExpression>$P{globalVisitCountPerPage}</dataSourceExpression>

</datasetRun>

</dataset>

</crosstabDataset>

 

and on the start of my jrxml:

<subDataset name="globalVisitCountPerPageDS">

<field name="pageName" />

<field name="userName" />

<field name="visits" class="java.lang.Long" />

</subDataset>

 

Th fields come from java code:

parameters.put("globalVisitCountPerPage", new JRBeanCollectionDataSource(someDao.getData()));

Link to comment
Share on other sites

Hmm.. Why isn't it well-formed?

The exception I showed doesn't tell anything about well-formed xml...

 

Exception:

net.sf.jasperreports.engine.JRException: Error at line 115 char 58: No such accessible method: setDataSourceExpression() on object: net.sf.jasperreports.crosstabs.design.JRDesignCrosstabDataset

 

at line 115 in my jrxml I have:

<dataSourceExpression >v</dataSourceExpression>

the exception is the same even if it looks like:

<dataSourceExpression >$P{globalVisitCountPerPage}</dataSourceExpression>

or

<dataSourceExpression ><![CDATA[$P{globalVisitCountPerPage}]]></dataSourceExpression>

 

I have no idea what is wrong :(

 

regards

Post edited by: adamzrk, at: 2007/02/20 13:52

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