Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Integrate BIRT 4.2.1 with JSF 2.0(Need to integrate BIRT report with JSF 2.0)
Integrate BIRT 4.2.1 with JSF 2.0 [message #937754] Tue, 09 October 2012 04:27 Go to next message
Izaak van Niekerk is currently offline 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 #938294 is a reply to message #937754] Tue, 09 October 2012 14:48 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Have you tried using BIRT tag library with JSF?
http://www.eclipse.org/birt/phoenix/deploy/viewerUsageMain.php#tags

Jason
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #942328 is a reply to message #938294] Sat, 13 October 2012 08:01 Go to previous messageGo to next message
Izaak van Niekerk is currently offline Izaak van Niekerk
Messages: 35
Registered: June 2010
Member
Hi Jason,

Thank you for replying. I have started reading about the tag library and will try to implement it immediately. It sounds perfect. I will let you know if I run into any problems, hoping it is as simple as it sounds? Razz




Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #942355 is a reply to message #942328] Sat, 13 October 2012 08:40 Go to previous messageGo to next message
Izaak van Niekerk is currently offline Izaak van Niekerk
Messages: 35
Registered: June 2010
Member
Jason, would you say this is the best way to integrate BIRT 4.2.1 with JSF 2.0 at the moment and secondly is there a step-by-step directions somewhere for this?? If not, perhaps we can post something somewhere once I get it working? Wink
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #942369 is a reply to message #942355] Sat, 13 October 2012 08:59 Go to previous messageGo to next message
Izaak van Niekerk is currently offline Izaak van Niekerk
Messages: 35
Registered: June 2010
Member
Hi Jason,

I am looking at the Viewer tag libraries solution and can't find any the mentioned libraries:

".. and copying coreapi.jar, modelapi,jar, viewerservlets.jar, engineapi.jar, and com.ibm.icu_version.jar from the Viewer libs "

Am I suppose to download them from somewhere or are these old jars? I'm using BIRT 4.2 right? I could find a viewservlets.jar for instance not a viewerservlets.jar. and the com.ibm.icu jar in the WebViewerExample/WEB-INF/lib/ folder of the BIRT Runtime package. Also what should the namespace def be for the taglib in my facelet? Do I need anything specific in my web.xml file?
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #942420 is a reply to message #942369] Sat, 13 October 2012 09:38 Go to previous messageGo to next message
Izaak van Niekerk is currently offline Izaak van Niekerk
Messages: 35
Registered: June 2010
Member
Ok this is how far I got:

1. added all runtime libs in my app (from WebViewerExample WEB-INF/lib folder).
2. web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    
        <!-- BIRT Servlets -->
    <servlet>
        <servlet-name>EngineServlet</servlet-name>
        <servlet-class>org.eclipse.birt.report.servlet.BirtEngineServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
      <servlet-name>ViewerServlet</servlet-name>
      <servlet-class>org.eclipse.birt.report.servlet.ViewerServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>ViewerServlet</servlet-name>
      <url-pattern>/frameset</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>EngineServlet</servlet-name>
      <url-pattern>/document</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>EngineServlet</servlet-name>
      <url-pattern>/download</url-pattern>
     </servlet-mapping>
    <servlet-mapping>
      <servlet-name>EngineServlet</servlet-name>
      <url-pattern>/parameter</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>EngineServlet</servlet-name>
      <url-pattern>/extract</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>ViewerServlet</servlet-name>
      <url-pattern>/run</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>EngineServlet</servlet-name>
      <url-pattern>/preview</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>EngineServlet</servlet-name>
      <url-pattern>/output</url-pattern>
    </servlet-mapping>
    
    
    <filter>
        <filter-name>ViewerFilter</filter-name>
        <filter-class>org.eclipse.birt.report.filter.ViewerFilter</filter-class>
    </filter>

    <filter-mapping>
      <filter-name>ViewerFilter</filter-name>
      <servlet-name>EngineServlet</servlet-name>
    </filter-mapping>

    <filter-mapping>
      <filter-name>ViewerFilter</filter-name>
      <servlet-name>ViewerServlet</servlet-name>
    </filter-mapping>

    <listener>
       <listener-class>org.eclipse.birt.report.listener.ViewerHttpSessionListener</listener-class>
     </listener>

     <listener>
       <listener-class>org.eclipse.birt.report.listener.ViewerServletContextListener</listener-class>
     </listener>

    
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>


3. Facelet (*.xhtml file)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:b="http://www.eclipse.org/birt/taglibs/birt.tld"
      xmlns:birt="urn:jsptld:/WEB-INF/tlds/birt.tld">
    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
        </h:head>

        <h:body>
            <p:layout fullPage="true">
                <p:layoutUnit position="north" size="100" resizable="true" closable="true" collapsible="true">
                    Header
                </p:layoutUnit>
                <p:layoutUnit position="south" size="100" closable="true" collapsible="true">
                    Footer
                </p:layoutUnit>
                <p:layoutUnit position="west" size="175" header="Left" collapsible="true">
                </p:layoutUnit>
                <p:layoutUnit position="center">
                    BIRT Viewer Tags
                    <birt:viewer id="birtViewer" reportDesign="transactions-report.rptdesign" pattern="frameset" height="450" width="700" format="html" />
                </p:layoutUnit>
            </p:layout>
        </h:body>

    </f:view>
</html>


4. Very simple BIRT report that doesn't take any paramters for now.

When I deploy the application on Glassfish, I don't see any errors, but unfortunately I don't see any viewer or report either. I only see my primefaces components.

What am I missing?
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #946283 is a reply to message #942420] Tue, 16 October 2012 00:40 Go to previous messageGo to next message
Jason Weathersby is currently offline 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

[Updated on: Tue, 16 October 2012 00:41]

Report message to a moderator

Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #947538 is a reply to message #946283] Wed, 17 October 2012 03:09 Go to previous messageGo to next message
Izaak van Niekerk is currently offline Izaak van Niekerk
Messages: 35
Registered: June 2010
Member
Hi James,

thank you for the detailed information and help! I finally got it working! BIRT on a JSF 2.0 facelet Smile
But it's only a prototype at the moment, so obviously need to still look at your suggestions of starting and stopping the engine within the application.

On another note, the report came back with quite a significant amount of data without any pagination resulting in the browser becoming almost unresponsive. Is there an easy way of automatically restricting the amount of records displayed with a sort of next, previous type navigation around the report data? And as for the save as pdf and excel buttons etc, I take it I need to build those myself and simply change the output format to PDF for example?
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #949348 is a reply to message #947538] Thu, 18 October 2012 19:19 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

You can always separate the tasks and have a run task that creates a rptdocument and then a render task to render specific pages or a page range.

engine = factory.createReportEngine( config );


IReportRunnable design = null;
design = engine.openReportDesign("Reports/Test.rptdesign");
IRunTask task = engine.createRunTask(design);
task.setLocale(new Locale("en", "US"));
task.run("output/resample/Test.rptdocument");
task.close();

document = engine.openReportDocument("output/resample/Test.rptdocument");

HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat("html");
options.setOutputFileName("output/resample/test.html");
options.setSupportedImageFormats("PNG;GIF;JPG;BMP;SWF;SVG");
options.setOption( IRenderOption.HTML_PAGINATION,Boolean.TRUE );

IRenderTask rtask = engine.createRenderTask(document);
rtask.setLocale(new Locale("en", "US"));
rtask.setRenderOption(options);
//rtask.setPageNumber(1);
//rtask.setPageRange("1,3-6");
rtask.render();
rtask.close();
document.close();

Jason
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #949349 is a reply to message #949348] Thu, 18 October 2012 19:22 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I am not certain this will help the performance though. It may be better to cut down the amount of data or look at implementing a progressive viewing scheme like what John Ward wrote up:
http://digiassn.blogspot.com/2007/10/birt-progressive-viewing-during-render.html
If you use John's approach make sure to not set birt home if you are using BIRT 3.7 or greater.

Jason
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #956153 is a reply to message #949349] Wed, 24 October 2012 05:29 Go to previous messageGo to next message
Izaak van Niekerk is currently offline Izaak van Niekerk
Messages: 35
Registered: June 2010
Member
Thank you Jason,

This is so helpful. Will try and implement either and let you know how it went!

Best Regards
Izaak
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #1031898 is a reply to message #956153] Tue, 02 April 2013 06:47 Go to previous messageGo to next message
Rajesh P is currently offline Rajesh P
Messages: 2
Registered: April 2013
Junior Member
I followed the above mentioned steps but I get the below exception. I have the iText2.1.7 lastest jar but still it gives the following error. I have been researching on this for couple of days, Can someone give solution for this.

---->
15:50:22,395 SEVERE [org.eclipse.birt.report.engine.api.impl.ReportEngine] Error happened while running the report.: java.lang.NoSuchMethodError: com.lowagie.text.pdf.PdfWriter.setRgbTransparencyBlending(Z)V
at org.eclipse.birt.report.engine.emitter.pdf.PDFPageDevice.<init>(PDFPageDevice.java:89) [Grin
at org.eclipse.birt.report.engine.emitter.pdf.PDFRender.createPageDevice(PDFRender.java:67) [Grin
at org.eclipse.birt.report.engine.layout.emitter.PageDeviceRender.start(PageDeviceRender.java:118) [Grin
at org.eclipse.birt.report.engine.layout.emitter.PageEmitter.start(PageEmitter.java:58) [Grin
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.start(LayoutEngine.java:327) [Grin
at org.eclipse.birt.report.engine.emitter.CompositeContentEmitter.start(CompositeContentEmitter.java:225) [Grin
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:179) [Grin
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #1031914 is a reply to message #937754] Tue, 02 April 2013 07:15 Go to previous messageGo to next message
Rajesh P is currently offline Rajesh P
Messages: 2
Registered: April 2013
Junior Member
i have tried with the steps mentioned by jason, but i am getting following error, while executing task.run & am also having corresponding jar(iText2.1.7.jar)

[org.eclipse.birt.report.engine.api.impl.ReportEngine] Error happened while running the report.: java.lang.NoSuchMethodError: com.lowagie.text.pdf.PdfWriter.setRgbTransparencyBlending(Z)V


if it is possible can anyone post me steps to integrate birt 4.2.1 with jsf 2.0.

am using RichFaces 4.2 and jboss 6.1.0 final,eclipse(juno)



can any one help me please.
Re: Integrate BIRT 4.2.1 with JSF 2.0 [message #1048139 is a reply to message #1031914] Wed, 24 April 2013 01:01 Go to previous message
Noor ul Huda is currently offline Noor ul Huda
Messages: 7
Registered: April 2012
Junior Member
I used managed bean in JSF for rendering birt report on birt viewer. Here is code:

package com.jsf.report.birt;

import java.io.IOException;

import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

@ManagedBean(name="birt")
public class BirtClass {

	public BirtClass() {
		System.out
				.println("-----------------------------------------------------------");
		System.out
				.println("-------------- BirtClass Default Constructor --------------");
		System.out
				.println("-----------------------------------------------------------");
	}

	private String URL = "/frameset?__report=reports/students.rptdesign";

	public void BirtViewer() throws IOException {
		HttpServletRequest request = (HttpServletRequest) (FacesContext
				.getCurrentInstance().getExternalContext().getRequest());
		URL = request.getContextPath() + URL;
		System.out.println("-----------------------------------------------------------");
		System.out.println("BirtViewer() :: Complete Report Path=\"" + URL + "\"");
		System.out.println("-----------------------------------------------------------");

		FacesContext.getCurrentInstance().getExternalContext().redirect(URL);

	}
}



Here is my JSF page with .xhtml extension:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:f="http://java.sun.com/jsf/core">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>.::JSF+Birt Application::.</title>
</head>
<body>
<h2 align="center">JSF_Birt Application</h2>
<h:form>
Click on View Button :
<h:commandButton id="btn" action="#{birt.BirtViewer}" type="submit" value="Preview Report"/>
</h:form>
</body>
</html>


Add birt configuration in web.xml and jsf servlet configuration also.
Previous Topic:How to avoid duplicate requests for Birt reports.
Next Topic:Can BIRT chart large time series
Goto Forum:
  


Current Time: Thu Jul 31 01:44:05 EDT 2014

Powered by FUDForum. Page generated in 0.02862 seconds