我想开发一个包含预先设计好的 pentaho 报告的小型 JSF 门户。我的问题是:如何嵌入 pentaho 报告以及如何将参数从 jsf 传递到报告引擎。谢谢。
问问题
1262 次
1 回答
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) {
}
于 2012-05-16T10:38:10.120 回答