Jump to content
Changes to the Jaspersoft community edition download ×

passing datasource expression for subreport


2005 IR Help

Recommended Posts

By: sathya - postsathya

passing datasource expression for subreport

2004-03-17 03:18

JRDesignSubreport subrep = new JRDesignSubreport();

JRDesignExpression exp = new JRDesignExpression();

JRDataSource datasrc = new JRTableModelDataSource(mod);

 

exp = new JRDesignExpression();

exp.setName("SubreportDataSourceExpression");

exp.setText("$P{"+JRParameter.REPORT_DATA_SOURCE+"}");

exp.setValueClass(datasrc);

subrep.setDataSourceExpression(exp);

 

 

the exception throwed is :

MySubReports.java:56: setValueClass(java.lang.Class) in dori.jasper.engine.design.JRDesignExpression cannot be applied to (dori.jasper.engine.JRDataSource)

exp.setValueClass(datasrc);

 

if i tried with .class it also doesnt works

[ exp.setValueClass(datasrc.class); ]

 

MySubReports.java:56: cannot resolve symbol

symbol : class datasrc

location: class MySubReports

exp.setValueClass(datasrc.class);

 

 

note that the datasrc is my datasource to the main report

here i pass the same to the subreport also

 

cud any body explain me how to pass the datasource class

thru this expression's setvalueclass();

 

NB: after srinivas learns to use separate datasources for the

main and subreports i 'll learn it from him ;-)

is the deal ok srinivas

 

 

 

 

 

By: srini - kapsljava

RE: passing datasource expression for subreport

2004-03-17 03:25

Hi sathya,

 

declare the parameter

parameter = new JRDesignParameter();

parameter.setName("SubReportDS");

parameter.setValueClass(dori.jasper.engine.JRDataSource.class);

jasperDesign.addParameter(parameter);

 

in the detail part

:modified code for u:

JRDesignSubreport subrep = new JRDesignSubreport();

JRDesignExpression exp = new JRDesignExpression();

 

exp = new JRDesignExpression();

exp.setName("SubreportDataSourceExpression");

exp.setText("$P{SubReportDS}");

exp.setValueClass(dori.jasper.engine.JRDataSource.class);

subrep.setDataSourceExpression(exp);

 

I hope it will work for u sathya.

 

From

Srinivas

 

 

 

 

 

 

By: sathya - postsathya

RE: passing datasource expression for subrepo

2004-03-17 03:35

But here I ve not specified about my own data source(datasrc)

how cud it take it and assign

 

 

 

 

By: srini - kapsljava

RE: passing datasource expression for subreport

2004-03-17 03:45

while you fill the main report, you have to pass the parameter for SubReport, SubReportDS

 

like

Map parameters = new HashMap();

parameters.put("SubReport",subReport); parameters.put("SubReportDS",new JRTableModelDataSource(mod));

 

and u pass this parameters while u filling main report.

 

 

 

 

By: David Lim - aberrant80

RE: passing datasource expression for subrepo

2004-03-17 04:04

Data sources are only needed during report filling. So when you're building your JasperDesign, it's not needed yet. You have to create your own parameters, or use the default REPORT_DATA_SOURCE parameter to pass it in when you're filling it.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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