Home > Crystal Report, Facelet, MyFaces > An Unexpected Behavior of Crystal Reports for Eclipse Plug-In with MyFaces and Facelet and Its Solution

An Unexpected Behavior of Crystal Reports for Eclipse Plug-In with MyFaces and Facelet and Its Solution


I was working with Crystal Report for Eclipse plug-in (version 1.4.0). After spending some minutes I easily developed a hello world type JSF application with JSP pages as view. But unfortunately the application was not working while I was trying to use Facelet as view handler. I quickly identified that the plug-in is missing Facelet tag library xml file. Then, I googled some minutes but not found any promising result. So I wrote a tag library xml file given below. Hopefully it will help others who are expecting a tag library file for using Crystal Report Page Viewer component with Facelet.

    bcorv.taglib.xml

<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>
http://www.businessobjects.com/jsf/crystalreportsviewers
</namespace>
<tag>
<tag-name>reportPageViewer</tag-name>
<component>
<component-type>CrystalReports.UIReportPageViewer</component-type>
<renderer-type>CrystalReports.ViewerHtmlRenderer</renderer-type>
</component>
</tag>
</facelet-taglib>

I included new tag library config file in web.xml. Now my hello world application seems working fine Buttttttt the scenario became more complicated while I want to navigate to another page or execute any other action from crystal report viewer’s toolbar. This time “MyFaces” shows an exception. This happened because “JPEReportSource” implements externalizable interface!!!!! My bad how can I solve it now? Fortunately, the viewer component accepts IReportSource component. So I wrote a provider given below.

    MyJPEReportSource.java

public class MyJPEReportSource implements IReportSource, Serializable {
private static final long serialVersionUID = 1L;
public JPEReportSource getJPEReportSource() {
ReportSourceMdl reportSourceMdl = (ReportSourceMdl) MyApplicationContext.getManagedBean("reportSourceMdl");
JPEReportSource rs = (JPEReportSource) MyApplicationContext.getFacesContext()
.getExternalContext().getSessionMap()
.get(reportSourceMdl.getReportSourceKey());
return rs;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#dispose()
*/
@Override
public void dispose() {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
rs.dispose();
}
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#drillGraph(com.crystaldecisions.sdk.occa.report.reportsource.IDrillDownRequestContext)
*/
@Override
public ITotallerNodeID drillGraph(IDrillDownRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
ITotallerNodeID nid = rs.drillGraph(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#drillReportPart(com.crystaldecisions.sdk.occa.report.reportsource.IDrillReportPartRequestContext)
*/
@Override
public ITotallerNodeID drillReportPart(IDrillReportPartRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
ITotallerNodeID nid = rs.drillReportPart(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#export(com.crystaldecisions.sdk.occa.report.exportoptions.IExportOptions, com.crystaldecisions.sdk.occa.report.reportsource.IRequestContext)
*/
@Override
public InputStream export(IExportOptions arg0, IRequestContext arg1)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
InputStream is = rs.export(arg0, arg1);
return is;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#findGroup(com.crystaldecisions.sdk.occa.report.reportsource.IFindGroupRequestContext)
*/
@Override
public int findGroup(IFindGroupRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
int g = rs.findGroup(arg0);
return g;
}
return 0;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#findText(com.crystaldecisions.sdk.occa.report.reportsource.IFindTextRequestContext)
*/
@Override
public int findText(IFindTextRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
int n = rs.findText(arg0);
return n;
}
return 0;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getClassFactoryName()
*/
@Override
public String getClassFactoryName() {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
String nid = rs.getClassFactoryName();
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getInitialReportPart()
*/
@Override
public ReportPartIDs getInitialReportPart() throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
ReportPartIDs nid = rs.getInitialReportPart();
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getInitialReportPartEx(com.crystaldecisions.sdk.occa.report.reportsource.IRequestContextBase)
*/
@Override
public ReportPartIDs getInitialReportPartEx(IRequestContextBase arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
ReportPartIDs nid = rs.getInitialReportPartEx(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getLastPageNumber(com.crystaldecisions.sdk.occa.report.reportsource.IRequestContext)
*/
@Override
public int getLastPageNumber(IRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
int nid = rs.getLastPageNumber(arg0);
return nid;
}
return 0;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getPage(com.crystaldecisions.sdk.occa.report.reportsource.IPageRequestContext)
*/
@Override
public InputStream getPage(IPageRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
InputStream nid = rs.getPage(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getParamPromptingInfo(com.crystaldecisions.sdk.occa.report.reportsource.IPromptingRequestInfo)
*/
@Override
public PropertyBag getParamPromptingInfo(IPromptingRequestInfo arg0)
throws ReportSDKException {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
PropertyBag nid = rs.getParamPromptingInfo(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getPromptDatabaseLogOnInfos(com.crystaldecisions.sdk.occa.report.reportsource.IPromptingRequestInfo)
*/
@Override
public ConnectionInfos getPromptDatabaseLogOnInfos(
IPromptingRequestInfo arg0) throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
ConnectionInfos nid = rs.getPromptDatabaseLogOnInfos(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getPromptParameterFields(com.crystaldecisions.sdk.occa.report.reportsource.IPromptingRequestInfo)
*/
@Override
public Fields getPromptParameterFields(IPromptingRequestInfo arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
Fields nid = rs.getPromptParameterFields(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getReportInfo(com.crystaldecisions.sdk.occa.report.reportsource.IRequestContextBase)
*/
@Override
public ReportInfo getReportInfo(IRequestContextBase arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
ReportInfo nid = rs.getReportInfo(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getReportParts(com.crystaldecisions.sdk.occa.report.reportsource.IReportPartRequestContext)
*/
@Override
public InputStream getReportParts(IReportPartRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
InputStream nid = rs.getReportParts(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getServerCapabilities()
*/
@Override
public PropertyBag getServerCapabilities() throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
PropertyBag nid = rs.getServerCapabilities();
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getTotaller(com.crystaldecisions.sdk.occa.report.reportsource.ITotallerRequestContext)
*/
@Override
public InputStream getTotaller(ITotallerRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
InputStream nid = rs.getTotaller(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#getTriggeredAlerts(com.crystaldecisions.sdk.occa.report.reportsource.IRequestContext)
*/
@Override
public Alerts getTriggeredAlerts(IRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
Alerts nid = rs.getTriggeredAlerts(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#navigateToReportPart(com.crystaldecisions.sdk.occa.report.reportsource.IReportPartNavigationRequestContext)
*/
@Override
public IReportPartNavigationResult navigateToReportPart(
IReportPartNavigationRequestContext arg0)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
IReportPartNavigationResult nid = rs.navigateToReportPart(arg0);
return nid;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#newReportSource(java.lang.Object, java.util.Locale)
*/
@Override
public Object newReportSource(Object arg0, Locale arg1)
throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
Object ob = rs.newReportSource(arg0, arg1);
return ob;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#refresh()
*/
@Override
public void refresh() throws ReportSDKExceptionBase {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
rs.refresh();
}
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#resolveParamPromptingResult(com.crystaldecisions.sdk.occa.report.reportsource.IPromptingRequestInfo, java.lang.Object)
*/
@Override
public PropertyBag resolveParamPromptingResult(IPromptingRequestInfo arg0,
Object arg1) throws ReportSDKException {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
PropertyBag pb = rs.resolveParamPromptingResult(arg0, arg1);
return pb;
}
return null;
}
/* (non-Javadoc)
* @see com.crystaldecisions.sdk.occa.report.reportsource.IReportSource#setReportSourceFactory(java.lang.Object)
*/
@Override
public void setReportSourceFactory(Object arg0) {
// TODO Auto-generated method stub
JPEReportSource rs = getJPEReportSource();
if(rs != null) {
rs.setReportSourceFactory(arg0);
}
}
}

Now it’s working fine. If you have any other idea please shares it here.

Advertisements
  1. param
    March 12, 2009 at 12:46 pm

    Hello 😉

    im working with crystal reports and jsf. Now i want to do facelets but the report viewer is not working. Can you please give me your example project?

    thx

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: