2014-01-15 30 views
0

當我將BIRT圖表報告加載到jsp中時出現問題..如果我爲報表使用表格,它會顯示很好,但是當我更改爲圖表時,它只是在我的jsp中顯示空白頁面。我怎麼解決這個問題 ??無法加載jsp中的BIRT圖表

這裏是我的html渲染。

public Resolution htmlReport() throws EngineException, SemanticException { 
      ByteArrayOutputStream reportOutput = new ByteArrayOutputStream(); 

      String path = getCompassContext().getServletContext().getRealPath(
        "/report"); 

      // @TODO 
      String user = getCompassContext().getUser().getUsername(); 
      birtReport.setUser(user); 
      birtReport.setBirtEngine(getCompassContext().getBirtEngine()); 

      path = CompassConfig.getBirtReport(); //+ "/login_time.rptdesign"; 
      birtReport.setReportDesignPath(path); 
      birtReport.setReportDesignName("/test.rptdesign"); 
      /** 
      * Generates the html report. 
      * 
      * @return forward to the jsp page 
      * @throws EngineException when opening report design or reunning the report 
      * @throws SemanticException when changing properties of DesignElementHandle 
      */ 
      // set output options 
       IHTMLRenderOption options = new HTMLRenderOption(); 

       options.setOutputFormat(IHTMLRenderOption.OUTPUT_FORMAT_HTML); 
       options.setOutputStream(reportOutput); 
       options.setEmbeddable(false); 
       // options.setBaseImageURL(context.getRequest().getContextPath() + "/images"); 
       //options.setImageDirectory(context.getServletContext().getRealPath("/images")); 
       options.setImageHandler(new HTMLServerImageHandler()); 
       options.setMasterPageContent(true); 

       birtReport.generateReport(options); 

       return new StreamingResolution("text/html", new ByteArrayInputStream(reportOutput.toByteArray())); 
      } 

這裏是我的BIRT引擎

public void generateReport(IRenderOption options) throws EngineException, 
      SemanticException { 

     generateParamaters(); 

     // get the engine 
     IReportEngine birtReportEngine = birtEngine; 

     // open the report design 
     String path = reportDesignPath + "/" + reportDesignName; 
     IReportRunnable design = birtReportEngine.openReportDesign(path); 

     // create task to run and render report 
     IRunAndRenderTask task = birtReportEngine 
       .createRunAndRenderTask(design); 

     Map<String, Object> appContext = task.getAppContext(); 
     Connection con = DataSourceUtils.getConnection(); 
     appContext.put("OdaJDBCDriverPassInConnection", con); 

     HashMap<String, String[]> multiValParam = getMultiValParam(); 
     if(multiValParam != null && multiValParam.size() > 0) { 
      Set<String> key = multiValParam.keySet(); 
      Iterator<String> ite = key.iterator(); 

      while(ite.hasNext()) { 
       String paramName = (String) ite.next(); 
       String[] paramValues = multiValParam.get(paramName); 

       task.setParameterValue(paramName, paramValues); 
      } 
     } 
     task.setParameterValues(getParameter()); 
     task.setRenderOption(options); 
     task.setAppContext(appContext); 

     // run report 
     task.run(); 
     task.close(); 
    } 

真正需要幫助的!!!!

回答

0

我就已經發現answer..you需要把裏面的HTML渲染下面setEmbeddable(真)

options.setBaseImageURL(getCompassContext()。Request()方法。getContextPath()+ 「/圖片」) ; ())getTevletContext()。getRealPath(「/ images」));

和需要把這個代碼生成報告內部下面appContext.put

DesignElementHandle reportChart = design.getDesignHandle()的GetModuleHandle()findElement( 「reportChart」)。。