当我在jasper报告中使用存储过程时,为什么会出现空白页?

时间:2015-03-30 12:16:19

标签: java jasper-reports

我在生成pdf报告时使用存储过程。但是,如果我不使用存储过程它没有任何问题,但当我使用存储过程时,我得到空页。 我在下面发布我的代码,我的代码是否有问题?

public void PDFDiploma(ActionEvent actionEvent) throws JRException,
        IOException, SQLException {

    String reportPath = FacesContext.getCurrentInstance()
            .getExternalContext()
            .getRealPath("/WEB-INF/report/Diploma.jasper");

    Authentication auth = SecurityContextHolder.getContext()
            .getAuthentication();
    String name = auth.getName();

    System.out.println("user name : :: : ::  : :: " + name);

    Connection conn;
    conn = DatabaseEngine.getConnection();

    System.out.println("Connection : " + DatabaseEngine.getConnection());

    Map jasperParameter = new HashMap();

    KpLoginDAO kpLoginDAO = new KpLoginDAO();
    KpLogin kpLogin = kpLoginDAO.findById(name);
    Long loginUserID = null;

    loginUserID = kpLogin.getKisi().getKisiid();

    Short prmOgrenciDuzey = (Short) actionEvent.getComponent()
            .getAttributes().get("prmOgrenciDuzey");
    Long prmKisiid = (Long) actionEvent.getComponent().getAttributes()
            .get("prmKisiid");

    Long prmOgrenimsureci = (Long) actionEvent.getComponent()
            .getAttributes().get("prmOgrenimsureci");

    String prmBelgeTuru = (String) actionEvent.getComponent()
            .getAttributes().get("prmBelgeTuru");

    System.out.println("loginUserID : " + loginUserID
            + " prmOgrenimsureci : " + prmOgrenimsureci
            + " prmBelgeTuru : " + prmBelgeTuru);

    System.out.println("prmOgrenciDuzey : " + prmOgrenciDuzey
            + " prmKisiid : " + prmKisiid + " prmOgrenimsureci : "
            + prmOgrenimsureci + " prmBelgeTuru : " + prmBelgeTuru);

    /*
     * VerilenbelgeDAO verilenBelgeDAO = new VerilenbelgeDAO(); Verilenbelge
     * verilenbelge = verilenBelgeDAO.findById(Long
     * .parseLong(prmBelgeTuru));
     * 
     * addAction(prmOgrenimsureci, loginUserID, verilenbelge);
     */

    String jrxmlFile = FacesContext.getCurrentInstance()
            .getExternalContext()
            .getRealPath("/WEB-INF/report/Diploma.jrxml");

    HttpServletRequest httpServletRequest = (HttpServletRequest) FacesContext
            .getCurrentInstance().getExternalContext().getRequest();

    JasperReport jasperReport = JasperCompileManager
            .compileReport(jrxmlFile);

    jasperParameter.put("v_KISIID", prmKisiid);
    jasperParameter.put("v_OGRENCIDUZEYI", prmOgrenciDuzey);
    jasperParameter.put("v_OGRENIMSURECIID", (long) 15220);
    System.out.println("---------------CON----------- : " + conn);
    jasperPrint = JasperFillManager.fillReport(reportPath, jasperParameter,
            conn);
    System.out
            .println("----------jasperprint------------ : " + jasperPrint);

    HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext
            .getCurrentInstance().getExternalContext().getResponse();
    httpServletResponse.addHeader("Content-disposition",
            "attachment; filename=Diploma.pdf");
    ServletOutputStream servletOutputStream = httpServletResponse
            .getOutputStream();
    // JasperRunManager.runReportToPdfStream(reportStream,
    // servletOutputStream, jasperParameter, conn);
    JasperExportManager.exportReportToPdfStream(jasperPrint,
            servletOutputStream);

    FacesContext.getCurrentInstance().responseComplete();

}

0 个答案:

没有答案