Jump to content
Changes to the Jaspersoft community edition download ×

Master report printed but not its subreport


Recommended Posts

By: Aurelia Ducreau - aurelia

Master report printed but not its subreport

2003-08-20 01:05

Hello,

 

 

I'm trying to edit on screen a master report containing a subreport in its detail band.

I succeeded in printing the master report but the subreport is not printed.

 

thanks

 

Aurelia

 

Here is a part of the java source :

 

public static Map parameters = new HashMap(); // Param to the master report

JasperReport jasperReport = null; // "Design"

JasperPrint jasperPrint = null;

Statement stmt = null;

ResultSet rs = null;

JRResultSetDataSource jrds = null;

Boolean queryChange = false;

 

// The master report...

File reportFile = new File( request.getRealPath( "/Profil/rapports/" + (String)parameters.get("rpt") + ".jasper" ) );

 

// The subreport...

File fileSR1=new File( request.getRealPath( "/Profil/rapports/SR_ListePersonnel_Eval.jasper" ));

 

try

{ // Loading subreport...

JasperReport subreport1 = (JasperReport)JRLoader.loadObject(fileSR1.getPath());

 

// Preparing parameters...

parameters.put("SR_PersonnelGroupDroits", subreport1);

 

// Loading master report...

jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());

 

// ... //

 

// Filling the master report...

 

if ( queryChange )

jasperPrint = JasperFillManager.fillReport( jasperReport, parameters, jrds );

else

jasperPrint = JasperFillManager.fillReport( jasperReport, parameters, dbCnx );

}

catch(JRException Ex)

{ AfficheErreurHTML( Ex , response); }

 

// Sending result (if exists) to the applet...

if (jasperPrint != null)

{

response.setContentType("application/octet-stream");

try{

ServletOutputStream ouputStream = response.getOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(ouputStream);

oos.writeObject(jasperPrint);

oos.flush();

oos.close();

}catch(Exception e){System.err.println("# ERREUR (1) dans JasperPrintServlet :"+e);}

 

}

else

{

AfficheInfoHTML("Le rapport est vide...", response);

}

 

 

 

 

 

By: Aurelia Ducreau - aurelia

RE: Master report printed but not its subreport

2003-08-20 06:01

I have found a solution:

 

1) load the "subreport.jasper" using JasperReport subreport = (JasperReport)JRLoader.loadObject(fileSR1.getPath());

 

2) fill and save the jrprint generated using the following method :

JasperFillManager.fillReportToFile(JasperReport subreport, String SubreportJRPrintName, Map parameters, Connection dbCnx);

e.g. : SubreportJRPrintName = "subreport.jrprint"

 

 

This way, I woud normally also avoid the problem with :

java.io.StreamCorruptedException: Caught EOFException while reading the stream header

 

Aurelia

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