By: Albert Chan - albertchan
Error creating Subreport using Java API
2003-12-11 14:17
Hi,
I have trouble creating a report with a subreport that only contains a static text. Here is my code snippet:
--------------------------------------------------
// create design
JasperDesign jDesign = new JasperDesign();
// create subreport
JRDesignSubreport jSubreport = new JRDesignSubreport();
jSubreport.setUsingCache(true);
jSubreport.setRemoveLineWhenBlank(true);
// create Detail band
JRDesignBand jDetailBand = new JRDesignBand();
jDetailBand.setHeight(50);
// set subreport connection
JRDesignExpression jSubreportConnExp = new JRDesignExpression();
jSubreportConnExp.addParameterChunk( JRParameter.REPORT_CONNECTION );
jSubreportConnExp.setValueClass(java.sql.Connection.class);
jSubreport.setConnectionExpression(jSubreportConnExp);
// set Subreport expression
JRDesignExpression jSubreportExp = new JRDesignExpression();
jSubreportExp.setValueClass( java.io.InputStream.class );
//testsub only contains a static text
jSubreportExp.setText( "testsub.jasper" );
jSubreport.setExpression(jSubreportExp);
jDetailBand.addElement(jSubreport);
jDesign.setDetail(jDetailBand);
--------------------------------------------------
When I tried to compile the Jasper design, I got this error:
--------------------------------------------------
/db/dbdev/jwsdp-1_0_01/bin/DetailQMEPostETLReport.java:217: cannot resolve symbol
symbol : variable testsub
location: class DetailQMEPostETLReport
value = (java.io.InputStream)(testsub.jasper);
^
/db/dbdev/jwsdp-1_0_01/bin/DetailQMEPostETLReport.java:355: cannot resolve symbol
symbol : variable testsub
location: class DetailQMEPostETLReport
value = (java.io.InputStream)(testsub.jasper);
^
/db/dbdev/jwsdp-1_0_01/bin/DetailQMEPostETLReport.java:493: cannot resolve symbol
symbol : variable testsub
location: class DetailQMEPostETLReport
value = (java.io.InputStream)(testsub.jasper);
^
3 errors
QMEReport_getReportDesign(WA053, DetailQMEPostETLReport): dori.jasper.engine.JRException: Errors were encountered when compiling report expressions class file:
See error messages above.
java.rmi.RemoteException: JRException: dori.jasper.engine.JRException: Errors were encountered when compiling report expressions class file:
See error messages above.
--------------------------------------------------
Even if I set the Subreport expression to:
jSubreportExp.setValueClass( String.class )
I still get the same kind of error....
Any suggestions?
Eventually, I would need to connect the subreport to a datasource, which I have no idea how to do.
Can you give me any directions on where to find good docs or samples?
Thanks in advance,
al
Error creating Subreport using Java API
2003-12-11 14:17
Hi,
I have trouble creating a report with a subreport that only contains a static text. Here is my code snippet:
--------------------------------------------------
// create design
JasperDesign jDesign = new JasperDesign();
// create subreport
JRDesignSubreport jSubreport = new JRDesignSubreport();
jSubreport.setUsingCache(true);
jSubreport.setRemoveLineWhenBlank(true);
// create Detail band
JRDesignBand jDetailBand = new JRDesignBand();
jDetailBand.setHeight(50);
// set subreport connection
JRDesignExpression jSubreportConnExp = new JRDesignExpression();
jSubreportConnExp.addParameterChunk( JRParameter.REPORT_CONNECTION );
jSubreportConnExp.setValueClass(java.sql.Connection.class);
jSubreport.setConnectionExpression(jSubreportConnExp);
// set Subreport expression
JRDesignExpression jSubreportExp = new JRDesignExpression();
jSubreportExp.setValueClass( java.io.InputStream.class );
//testsub only contains a static text
jSubreportExp.setText( "testsub.jasper" );
jSubreport.setExpression(jSubreportExp);
jDetailBand.addElement(jSubreport);
jDesign.setDetail(jDetailBand);
--------------------------------------------------
When I tried to compile the Jasper design, I got this error:
--------------------------------------------------
/db/dbdev/jwsdp-1_0_01/bin/DetailQMEPostETLReport.java:217: cannot resolve symbol
symbol : variable testsub
location: class DetailQMEPostETLReport
value = (java.io.InputStream)(testsub.jasper);
^
/db/dbdev/jwsdp-1_0_01/bin/DetailQMEPostETLReport.java:355: cannot resolve symbol
symbol : variable testsub
location: class DetailQMEPostETLReport
value = (java.io.InputStream)(testsub.jasper);
^
/db/dbdev/jwsdp-1_0_01/bin/DetailQMEPostETLReport.java:493: cannot resolve symbol
symbol : variable testsub
location: class DetailQMEPostETLReport
value = (java.io.InputStream)(testsub.jasper);
^
3 errors
QMEReport_getReportDesign(WA053, DetailQMEPostETLReport): dori.jasper.engine.JRException: Errors were encountered when compiling report expressions class file:
See error messages above.
java.rmi.RemoteException: JRException: dori.jasper.engine.JRException: Errors were encountered when compiling report expressions class file:
See error messages above.
--------------------------------------------------
Even if I set the Subreport expression to:
jSubreportExp.setValueClass( String.class )
I still get the same kind of error....
Any suggestions?
Eventually, I would need to connect the subreport to a datasource, which I have no idea how to do.
Can you give me any directions on where to find good docs or samples?
Thanks in advance,
al
0 Answers:
No answers yet