2012-04-14 161 views
-3

我想開發一個包含預先設計的pentaho報告的小JSF門戶。我的問題是:如何嵌入pentaho報告以及如何將參數從jsf傳遞到報表引擎。謝謝。Pentaho報告+ JSF

+0

你讀過http://wiki.pentaho.com/display/COM/Pentaho+reports+integration+with+portlets+web+application? – Daniel 2012-04-14 18:57:07

+0

該教程討論調用基於XACTION的報告,那不是我所需要的,我希望你有資格回答這個問題:) – 2012-04-16 23:02:49

+0

我剛剛注意到jsf在那裏被提及...認爲它可能會幫助你...我沒有回答你的問題,只是發佈了一條評論... btw雖然做了一個短的谷歌搜索,我注意到它被別人推薦使用差異報告引擎,而JSF(不是100%肯定) – Daniel 2012-04-17 05:30:44

回答

0
final FacesContext context = FacesContext.getCurrentInstance(); 
ClassicEngineBoot.getInstance().start(); 
try { 
    // load report definition 
    ResourceManager manager = new ResourceManager(); 
    manager.registerDefaults(); 
    manager.registerDefaultLoaders(); 

    ExternalContext extContext = context.getExternalContext(); 

    String reportPath = "file:" + extContext.getRealPath("aaaaaaaaaaaaa.prpt"); 

    Resource res = manager.createDirectly(new URL(reportPath), MasterReport.class); 
    MasterReport report = (MasterReport) res.getResource(); 
    report.getParameterValues().put("x1","%" + current.getx1() +"%"); 
    report.getParameterValues().put("x2","%" + current.getx2() +"%"); 

    HttpServletResponse httpServletResponse = 
    (HttpServletResponse) extContext.getResponse(); 
    httpServletResponse.setContentType("application/rtf"); 
    httpServletResponse.setHeader("Content-Disposition", 
    "attachment; filename=\"bbbbbbbbb.rtf\""); 

    RTFReportUtil.createRTF(report, httpServletResponse.getOutputStream()); 
    FacesContext.getCurrentInstance().responseComplete(); 
} catch (ReportProcessingException ex) { 
}