Small Talks/2009/July/Integrating Birt with ZK
From Documentation
Contents |
Pre-requisites
Getting start
- Download ZkBirt.zip and unzip it to a directory.
- 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.
You can create your own report ( test.rptdesign ) to test.
| Copyright © Danilo de Sousa. This article is licensed under GNU Free Documentation License. |
TOC
July
Installation Guide for Eclipse 3.5 (Galileo) 