I am using JRC to view crystal reports in porlet based web application. Following is the code in JSP
<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer,
com.crystaldecisions.sdk.occa.report.application.OpenReportOptions,
com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,
com.crystaldecisions.sdk.occa.report.lib.ReportSDKExceptionBase" %>
<portlet:defineObjects />
<%
// This sample code calls methods from the CRJavaHelper class, which
// contains examples of how to use the BusinessObjects APIs. You are free to
// modify and distribute the source code contained in the CRJavaHelper class.
try {
String reportName = "ProactiveEventsSummaryData.rpt";
ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
if (clientDoc == null) {
// Report can be opened from the relative location specified in the CRConfig.xml, or the report location
// tag can be removed to open the reports as Java resources or using an absolute path
// (absolute path not recommended for Web applications).
clientDoc = new ReportClientDocument();
//clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
clientDoc.setReportAppServer("inproc:jrc");
// Open report
clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
// Store the report document in session
session.setAttribute(reportName, clientDoc);
}
// ****** BEGIN CONNECT CRYSTALREPORTPAGEVIEWER SNIPPET ****************
{
// Create the CrystalReportViewer object
CrystalReportViewer crystalReportPageViewer = new CrystalReportViewer();
String reportSourceSessionKey = reportName+"ReportSource";
Object reportSource = session.getAttribute(reportSourceSessionKey);
if (reportSource == null)
{
reportSource = clientDoc.getReportSource();
session.setAttribute(reportSourceSessionKey, reportSource);
}
// set the reportsource property of the viewer
crystalReportPageViewer.setReportSource(reportSource);
// Apply the viewer preference attributes
// Process the report
crystalReportPageViewer.processHttpRequest(request, response, application, null);
}
// ****** END CONNECT CRYSTALREPORTPAGEVIEWER SNIPPET ****************
} catch (ReportSDKExceptionBase e) {
out.println(e);
}
%>
With this code , report gets displayed in the portlet but none of the actions on thre report like next page click , search button , opening subreport , clicking on drill-downs are working . The error in the explorer console is as shown below
Error: CrystalViewerCrystalEvent is not defined
javascript:CrystalViewerCrystalEvent('CrystalViewer',%20'tb=next')
PageSource of the web page shows the CrystalViewerCrystalEvent javascript function defined but for somereason its not recognized by the portlet. Has anyone worked on displaying crystalreports in a portlet ?