Integrating crystal reports with zk
From Documentation
Revision as of 08:32, 20 September 2010 by Elton776 (talk | contribs) (moved Small Talks/Integrating crystal reports with zk to Small Talks/2009/November/Integrating crystal reports with zk)
Author
Ramkumar, Project Leader, Prodigy Infomatics (PRODIGY)
Ramkumar, Project Leader, Prodigy Infomatics (PRODIGY)
Ramkumar is a Software Professional and has been working with Java Technologies since 2002. He has worked on various evolving java concepts from Servlets, JSP, EJB, Struts, Hibernate to Toplink. He has a passion for learning and adopting evolving concepts in day to day programming to deliver business results and performance. He now works on various concepts including Rich Internet Applications - ZK, Crystal Reports Server, Android, GWT. His free time spending goes on researching alfresco, clustering, etc.
Date
November 24, 2009
November 24, 2009
Version
ZK Studio 0.9
ZK Studio 0.9
Integerating Crystal Reports with ZK
Abstract
This document describes the tools and methods to achive Crystal Report Integeration with zk
Prerequisites:
- Java SDK Download or later
- ZK 3.6 or later
- Eclipse Galileo
- Tomcat 6
- Crystal Reports Server 2008
- MySql
Getting Started:
- Install Java
- Install Tomcat 6
- Install MySQL (Required for Crystal Report Server 2008 to install)
- Install Crystal Reports Server 2008
- Configure Eclipse with & ZK
You need to have eclipse, ZK, Tomcat 6, Crystal Reports Server 2008 and Jave for the given example to work. This is being done on windows platform.
Initiation:
- Check tomcat is working by checking the URL http://<ip or hostname>:<Portnumber>/
- Check whether the Crystal report server is running by Navigating to Program Files->Crystal Reports Server 2008->Crystal Reports Server 2008->Central Configuration Manager(CCM)
- Both of the services mentioned in the CCM must be in the running Status
- To enable the users to access the crystal report server you to Login using the Crystal Report Diagnostic Tool. Program Files->Crystal Reports Server 2008->Crystal Reports Server 2008->Dignostic Tools
- Login with the Administrator Username and password which you have given during installation of Crystal Report Server
- As soon as you have completed the installation you will sample reports in the directory Structure Program files\Business Objects\Business Objects Enterprise 12.0\Samples\En\Reports\Demonstration
- You will find sample reports in that folder
Integeration with ZK:
Now lets see how we will be accessing the Reports by integerating Crystal Reports to the ZK
- Start Eclipse
- Project Explorer->New Project->ZK Project
- Lets have the name of the project as ZKCRIntegeration, click Next
- Click next and finish
- Now we will need to include the nececssary jar files for the development process (The import fact here is the JAR files needs to be proper else you might face getlocale problem)
- JAR files required for development can be found in the folder Program Files\Business Objects\Common\4.0\Java\lib
- JAR files needed are listed below: (Quite Lengthy)
- Crystalreportviewer folder is necessary to be in the WebContent folder to view the crystal reports
- We are using world sales Report example report from Crystal report Server 2008 in this example
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/activation-1.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/asn1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/axiom-api-1.2.5.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/axiom-impl-1.2.5.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/axis2-saaj-1.3.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/axis2-xmlbeans-1.3.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/backport-util-concurrent-2.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/biarengine.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/biplugins.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/boconfig.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/bsh.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/cecore.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/celib.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/ceplugins_client.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/ceplugins_core.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/ceplugins_cr.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/cereports.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/certj.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/cesession.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/cetaglib.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/ceutils.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/clientlogic.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/clientplugins.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-beanutils.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-collections-3.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-collections.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-configuration-1.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-digester.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-el.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-fileupload-1.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-fileupload.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-httpclient-3.0.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-io.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-lang-2.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-logging.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/Concurrent.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/corbaidl.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/crdataprovider_en.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/crdataprovider.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/CrystalReports_en.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/CrystalReports.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/derby.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dojoz.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dsws-bicatalog.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dsws-biplatform.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dsws-common.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dsws-federator.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dsws-publish.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dsws-queryservice.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dsws-reportengine.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dsws-session.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/ebus405.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/explorer_jdbc.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/explorer_jsf.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/explorer_model_sdk.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/explorer_model.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/explorer_res_en.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/explorer_sap_en.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/explorer_sap.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/fckez.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/Filters.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/flash.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/freessl201.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/gmapsz.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/groovy.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/icu4j.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/itext.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jasperreports.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jawin_1.0.18.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jcommon.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jdom-beta8.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jfreechart.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jruby.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/js.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jsafe.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jsf-api.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jsf-impl.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/json_simple.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jstl.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jtools.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jxl.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jython.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/keycodeDecoder.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/log4j.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/logging.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/mail.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/MetafileRenderer.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/mvel.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/mysql-connector-java-5.1.6-bin.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/ognl.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/pluginhelper.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/poi.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/pub_common_en.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/pub_common.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/rasapp.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/rascore.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/rebean.common.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/rebean.fc.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/rebean.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/rebean.wi.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/reportsourcebridge_en.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/reportsourcebridge.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/reporttemplate.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/rpoifs.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/serialization.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/servlet.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/SL_plugins.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/sslj.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/standard.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/stax-api-1.0.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/struts.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/timelinez.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/timeplotz.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/URIUtil.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/webapp_en.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/webapp-struts.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/webapp.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/webreporting-jsf.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/webreporting.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/webutil_en.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/webutil.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/wilog.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/wsdl4j-1.6.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/wstx-asl-3.2.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xalan.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xbean.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xcelsius.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xercesImpl.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xml-apis.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/XmlSchema-1.3.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xpp3.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zcommon.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zcommons-el.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zhtml.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zk.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zkex.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zkflash.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zkmax.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zkplus.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zml.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zul.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zul2jsp.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/zweb.jar"/>
Source:
index.zul
<window width="100%" title="Example Crystal Report" border="normal"
apply="com.prodigy.report.controller.ReportController">
<iframe id="report" width="100%" height="100%" />
<div align="center">
<button id="getReport" label="Get Report"></button>
</div>
</window>
ReportController.java
public class ReportController extends GenericForwardComposer {
private static final long serialVersionUID = 1L;
private Iframe report;
private String url = "/run?__report=World Sales Report";
public void onClick$getReport() {
report.setSrc(url);
}
}
WebReport.Java
public class WebReport extends HttpServlet {
private static final long serialVersionUID = 1L;
public WebReport() {
super();
}
@Override
public void destroy() {
super.destroy();
}
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String report = request.getParameter("__report");
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
//Username, Servername and Password has to be based on the Crystal Report server
IEnterpriseSession enterpriseSession = sessionMgr.logon("Administrator", "", "Sonam:6400", "secEnterprise");
IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
IUserInfo us = enterpriseSession.getUserInfo();
us.setPreferredViewingLocale(Locale.ENGLISH);
// Retrival of Report from IInfoObjects which can be found in mysql
IInfoObjects result = iStore.query("Select SI_ID, SI_NAME From CI_INFOOBJECTS Where SI_NAME = '" + report
+ "'" + " And SI_INSTANCE = 0");
iStore.commit(result);
IInfoObject infoObject = (IInfoObject) result.get(0);
IReportSourceFactory reportFactory = null;
Object reportSource = null;
reportFactory = (IReportSourceFactory) enterpriseSession.getService("", "PSReportFactory");
reportSource = reportFactory.openReportSource(infoObject, Locale.ENGLISH);
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setReportSource(reportSource);
viewer.setDisplayPage(true);
viewer.setDisplayToolbar(true);
viewer.setOwnPage(true);
viewer.setEnableDrillDown(true);
viewer.setEnableLogonPrompt(true);
viewer.setEnableParameterPrompt(true);
viewer.setProductLocale(Locale.ENGLISH);
viewer.setProductLocale(Locale.ENGLISH);
viewer.processHttpRequest(request, response, getServletContext(), null);
} catch (ReportSDKException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
@Override
public void init() throws ServletException {
}
}
Web.xml
<context-param>
<param-name>crystal_image_uri</param-name>
<param-value>/crystalreportviewers</param-value>
</context-param>
<context-param>
<param-name>crystal_image_use_relative</param-name>
<param-value>webapp</param-value>
</context-param>
....
<servlet>
<servlet-name>report</servlet-name>
<servlet-class>com.prodigy.report.servlet.WebReport</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>report</servlet-name>
<url-pattern>/run</url-pattern>
</servlet-mapping>
Output:
Download Source
Comments
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |