Integrating Birt with ZK

From Documentation
Revision as of 08:43, 10 September 2010 by Elton776 (talk | contribs) (Created page with '{{Template:Smalltalk_Author| |author=Danilo de Sousa, Developer, Banco Comercial e de Investimentos ([http://www.bci.co.mz/ BCI]). |date=July 07, 2009 |version= }} =Pre-requisit…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
DocumentationSmall Talks2009JulyIntegrating Birt with ZK
Integrating Birt with ZK

Author
Danilo de Sousa, Developer, Banco Comercial e de Investimentos (BCI).
Date
July 07, 2009
Version

Pre-requisites

Getting start

  1. Download ZkBirt.zip and unzip it to a directory.
  2. Use Eclipse to import the project using [Import Existing Project]

Project folder:

ZkBirt
|-- src
|---- BirtConfig.properties
|---- com/dsousa/birt/BirtEngine.java
|---- com/dsousa/birt/servlet/WebReport.java
|---- com/dsousa/zk/controller/ReportController.java
|-- WebContent
|---- META-INF
|---- WEB-INF
|------ classes
|------ lib // copy libs from zk and from $BIRT$/WebViewerExample/WEB-INF/lib
|------ platform // copy from $BIRT$/WebViewerExample/WEB-INF/platform
|-------- configuration
|-------- plugins
|------ zk.xml
|------ web.xml
|---- Reports
|------test.rptdesign
|---- index.zul

Source

Lets see each file.

BirtConfig.properties , BirtEngine.java and WebReport.java You can find in BIRT Examples

ReportController.java

import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zul.Iframe;
import org.zkoss.zul.Window;


public class ReportController extends Window implements AfterCompose
{
	private static final long serialVersionUID = 1L;
	private Iframe iframe;

	public void afterCompose()
	{
		Components.wireVariables(this, this);
		Components.addForwards(this, this);
	}

	public void onClick$btReport()
	{
		String url = "/run?__report=test.rptdesign";
		iframe.setSrc(url);
	}

}


web.xml

...
	
	<servlet>
		<servlet-name>birtReport</servlet-name>
		<servlet-class>com.dsousa.birt.servlet.WebReport</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>birtReport</servlet-name>
		<url-pattern>/run</url-pattern>
	</servlet-mapping>
...


index.zul

<window title="BIRT and ZKOSS" border="normal" id="main"
	use="com.dsousa.zk.controller.ReportController" width="700px"	height="550px">

	<vbox width="100%" height="100%">		
		<iframe id="iframe" width="680px" height="100%" />
		<button id="btReport" label="Run report" />
	</vbox>

</window>

The Result

If you run the application successfully, simply clicks the button, and you shall see the result.
Birt result.png

You can create your own report ( test.rptdesign ) to test.

Copyright © Danilo de Sousa. This article is licensed under GNU Free Documentation License.