| Integrate BIRT 4.2.1 with JSF 2.0 [message #937754] |
Tue, 09 October 2012 04:27  |
Izaak van Niekerk Messages: 35 Registered: June 2010 |
Member |
|
|
I am trying to integrate BIRT 4.2.1 with JSF 2.0 (we're using Primcefaces 3.4) running on Glassfish 3.1.2.2.
We are busy investigating all possible open source solutions for our reporting engine needs. BIRT seemed perfect except that we are unable to integrate it with our JSF 2.0 GUI. I have googled and found jsf4birt but the library does not seem to support JSF 2. Also busy looking at jboss-birt-servlet.jar but have not had any success.
In essence, any suggestions/help on this matter will be highly appreciated? Is there anyway to integrate BIRT with JSF 2.0 and where can I find more information on how to accomplish this? Surely this can not be too difficult?
|
|
|
|
|
|
|
|
| Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #946283 is a reply to message #942420] |
Tue, 16 October 2012 00:40   |
Jason Weathersby Messages: 9167 Registered: July 2009 |
Senior Member |

|
|
I know there have been some issues with JSF 2.0.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=367192
A couple of options. One is to deploy the viewer to a separate web app and then use url integration to the birt viewer app. Another option alluded to in the bug is to use the h:outputText tag
http://www.mkyong.com/jsf2/jsf-2-outputtext-example/
Download the runtime for birt 4.2 add all the jars in the report engine/lib directory to your webapp classpath and then call the Report Engine API to create and render the report in HTML.
RunAndRenderTask task = null;
IReportEngine engine = null;
EngineConfig config = null;
try {
config = new EngineConfig();
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
IReportRunnable design = null;
// Open the report design
design = engine.openReportDesign("Reports/myreports.rptdesign");
task = (RunAndRenderTask) engine.createRunAndRenderTask(design);
task.setLocale(new Locale("en", "US"));
HTMLRenderOption options = new HTMLRenderOption();
options.setSupportedImageFormats("JPG;PNG;BMP;SVG;GIF");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
options.setOutputStream(bos);
options.setOutputFormat("html");
options.setEmbeddable(true);
task.setRenderOption(options);
task.run();
task.close();
engine.destroy();
} catch (Exception ex) {
ex.printStackTrace();
}
Platform.shutdown();
System.out.println("Finished");
If you use this approach make sure to only startup the platform once when your app starts up. Shut it down when your app is closing. Wrap access to the engine creation code in a singleton and create a new task with the engine for every report request. Also make sure to close the task when the report is complete.
Jason
Jason Weathersby
BIRT Exchange
[Updated on: Tue, 16 October 2012 00:41] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07717 seconds