This sample shows you how to use the Viewer Tag Library to display a report using a report source obtained from a managed Report Application Server.
<%@ taglib uri="/crystal
<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %>
<%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>
<%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>
<%@ page import="com.crystaldecisions.sdk.occa.managedreports.*" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObject" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObjects" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSourceFactory2" %>
In this case, the default administrator account is used to log on to a Crystal Enterprise installation running on the same machine as the application server.
<%
IEnterpriseSession es = CrystalEnterprise.getSessionMgr().logon("administrator", "", "localhost", "secEnterprise");
IInfoStore infoStore = (IInfoStore) es.getService("", "InfoStore");
IInfoObjects infoObjects = infoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='World Sales Report'");
IInfoObject report = (IInfoObject) infoObjects.get(0);
IReportSourceFactory2 reportFactory = (IReportSourceFactory2) es.getService ("", "RASReportFactory");
Object reportSource = reportFactory.createReportSource(report, request.getLocale());
This allows it to be retrieved by the viewer.
session.setAttribute("ReportSource", reportSource);
%>
In this case, the report source type is reportApplicationServer, and the report source variable refers to the session variable where you stored the ReportSource object.
<html>
<body>
<crviewer:viewer viewerName="CrystalViewer" reportSourceType="reportApplicationServer" reportSourceVar="ReportSource" />
</body>
</html>
Note: In this case, a report tag is not needed because the report source has already been cached in a session variable and does not need to be retrieved by the viewer.
Business Objects http://www.businessobjects.com/ Support services http://www.businessobjects.com/services/support/ |