I would like to show a subreport in the mainreport, but it doesn't show.

in the method showPdfList() builds the pdf

what's wrong?

thanks for help!!!

/**
* Hier wird das PDF mit den Partnern erstellt.
* @return "success"
* @throws Exception
*/
public String showPdfList() throws Exception {
LogBuilder.getLog(PartnerListBean.class).debug("cr eate partner and contract list pdf...");

final FacesContext facesContext = FacesContext.getCurrentInstance();
// Now we create some variables we will use for writing
// the file to the response

// Name des jrxml
final String mainFileName = "partnerList";
final String subFileName = "contractList_subreport";

String fileExt = ".jrxml";
final String base = JasperReportHelper.getJasperConfDirRealPath();

OutputStream outputStream = null;
JasperReport jasperMainReport = null;
JasperReport jasperSubReport = null;
if (base != null) {
try {
final Map<String, JasperReport> params = new HashMap<String, JasperReport>();

// compile main report
// this ist also done in mavens pre-compilation, see: jasperreports-maven-plugin
final JasperDesign jasperDesign = JRXmlLoader.load(base + mainFileName + fileExt);

final JasperDesign subJasperDesign = JRXmlLoader.load(base + subFileName + fileExt);
jasperSubReport = JasperCompileManager.compileReport(subJasperDesign );
jasperMainReport = JasperCompileManager.compileReport(jasperDesign);
params.put("subreport", jasperSubReport);

// eine Collection mit der aktuellen Liste
final JRBeanCollectionDataSource mainCollection =
new JRBeanCollectionDataSource(this.getList());

//eine Collection mit der aktuellen Liste
// final JRBeanCollectionDataSource subCollection =
// new JRBeanCollectionDataSource(this.getList());

final JasperPrint mainJasperPrint = JasperFillManager.fillReport(jasperMainReport, params,
mainCollection);
// final JasperPrint subJasperPrint = JasperFillManager.fillReport(jasperSubReport, params,
// subCollection);

LogBuilder.getLog(PartnerListBean.class).debug("An zahl Partner der Liste: "
+ list.size());

fileExt = ".pdf";

// check if response not null
HttpServletResponse response = null;
if (facesContext != null & facesContext.getExternalContext() != null && facesContext.getExternalContext().getResponse() != null) {

// Then we have to get the Response where to write our file
response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
}

if (response != null) {
// Then we have to get the Response where to write our file
response = (HttpServletResponse) facesContext.getExternalContext().getResponse();

// Now set the content type for our response, be sure to use the
// best suitable content type depending on your file
// the content type presented here is ok for, lets say, text
// files and others (like CSVs, PDFs)
response.setContentType("application/pdf");

// This is another important attribute for the header of the response
// Here fileName, is a String with the name that you will suggest as
//a name to save as
// I use the same name as it is stored in the file system of the server.
response.setHeader("Content-Disposition",
"attachment;filename=\"" + mainFileName + fileExt + "\"");

outputStream = response.getOutputStream();
JasperExportManager.exportReportToPdfStream(mainJa sperPrint,
outputStream);
} else {
LogBuilder.getLog(PartnerListBean.class).warn(
"we have no response object, writing to pdf file not to response");
JasperExportManager.exportReportToPdfFile(mainJasp erPrint, base + mainFileName + fileExt);
}
} catch (JRException ex) {
LogBuilder.getLog(PartnerListBean.class).error(ex, ex);
return "";
} catch (IOException ex) {
LogBuilder.getLog(ContractListBean.class).error(ex , ex);
return "";
} finally {
if (outputStream != null) {
try {
outputStream.flush();
outputStream.close();
} catch (IOException ioe) {
LogBuilder.getLog(PartnerListBean.class).warn(ioe, ioe);
}
}
}
} else {
// Warn logging
LogBuilder.getLog(PartnerListBean.class).warn(
"Base of Jasper-Reporter was null, no PDF created");
return "success";
}

// we are finished
if (facesContext != null) {
facesContext.responseComplete();
}
LogBuilder.getLog(PartnerListBean.class).debug("cr eate contract list pdf -> done");
return "success";
}