Jump to content
Changes to the Jaspersoft community edition download ×

Subreport trouble... please help


2005 IR Help

Recommended Posts

By: Joe Hudson - jhudson8

Subreport trouble... please help

2004-09-14 19:13

Hello, I'm just trying to get a simple subreport working. When I try to create the master report I do not receive an Exception and I get the master PDF however, the section that the subreport should be in just shows up as blank. Can someone help me? I have pasted information below to reference what I am doing. Thank you very much.

 

-------------- JAVA CODE --------------------------------------------

// get the subreport and set the parameter as "

JasperReport report = getReport(getReportDirectory() + "RentalApplicationReferences");

Map parameters = new HashMap();

parameters.put("ReferencesReport", report);

 

// create the master report

report = (JasperReport) getReport();

JasperPrint print = JasperFillManager.fillReport(report, parameters, jasperDataSource);

JasperExportManager.exportReportToPdfStream(print, res.getOutputStream());

 

-------------- SUBREPORT DEFINITION IN MASTER REPORT ---------------

// below is the subreport definition in the master report

// I'm trying to pass a collection to a JRBeanCollectionDataSource but I have extended it just to take an object in the constructor

// and pass in the collection because the References parameter is defined as a java.lang.Object.

// I have also passed in as a parameter the ReferencesReport which is another JasperReport.

<subreport>

<reportElement positionType="Float" x="6" y="474" width="546" height="86"/>

<dataSourceExpression><![CDATA[new com.myadbox.web.form.JRBeanCollectionDataSource($F{References})]]></dataSourceExpression>

<subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{ReferencesReport}]]></subreportExpression>

</subreport>

 

 

--------------- ACTUAL SUBREPORT DEFINITION --------------

// below is the definition for the subreport... I'm just trying to get it to work so I'm printing out some text

<jasperReport name="Unnamed" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30">

<title>

<band height="50">

<staticText>

<reportElement positionType="Float" x="130" y="12" width="131" height="30"/>

<textElement>

<font size="16"/>

</textElement>

<text><![CDATA[FOO BAR]]></text>

</staticText>

</band>

</title>

</jasperReport>

 

 

 

 

By: Franco Weichel - franco_weichel

RE: Subreport trouble... please help

2004-09-15 09:04

Hi,

 

perhaps because your subreports pagewidht is greate then the space you reserve in the master Report, just a guess.

 

try

pageWidth="270" pageHeight="120" columnWidth="270" leftMargin="0" rightMargin="0"

 

in the Subreport.

 

Franco

 

 

 

 

By: Joe Hudson - jhudson8

RE: Subreport trouble... please help

2004-09-15 19:06

Thank you for replying. I have made the change you suggested but am still receiving the same result. This is my first attempt at creating a subreport. Does it look like I am doing it correctly? Thanks.

 

Joe

 

 

 

 

By: Franco Weichel - franco_weichel

RE: Subreport trouble... please help

2004-09-16 08:38

Does your SubreportDatasource contains data?

 

Try to add

<jasperReport ...whenNoDataType="AllSectionsNoDetail"...

 

 

 

 

 

 

By: Joe Hudson - jhudson8

RE: Subreport trouble... please help

2004-09-22 14:57

Hi Franco, I really appreciate your reply however, I still have the same results. I am receiving no error, but I do not see the sub report text at all (even the title). Do you, by any chance, have any more ideas?

 

Joe

 

 

 

 

By: Franco Weichel - franco_weichel

RE: Subreport trouble... please help

2004-09-23 05:52

I tested your xml definiton in a sample report, adjusted the positions and sizes a little so that i did not get a warning when i compile the reports.

 

I could see the 'FOO BAR' in my report.

 

Franco

 

 

 

 

By: Joe Hudson - jhudson8

RE: Subreport trouble... please help

2004-09-25 11:16

Thank you Franco.

 

I'm still having trouble for some reason. Would you mind posting the working report so I can try to compare to see what I am doing wrong? Thanks very much.

 

Joe

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