Viewing a report using a managed RAS server

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.

To view a report using a managed RAS server
  1. Import the appropriate classes and libraries
  2. <%@ taglib uri="/crystal-tags-reportviewer.tld" prefix="crviewer" %>

    <%@ 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" %>

  3. Log on to Crystal Enterprise and get an InfoStore object.
  4. 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");

  5. Query for the report you wish to view.
  6. IInfoObjects infoObjects = infoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='World Sales Report'");

        IInfoObject report = (IInfoObject) infoObjects.get(0);

  7. Create a RAS report source for the report you retrieved.
  8.     IReportSourceFactory2 reportFactory = (IReportSourceFactory2) es.getService ("", "RASReportFactory");

        Object reportSource = reportFactory.createReportSource(report, request.getLocale());

  9. Cache the ReportSource object in a session variable.
  10. This allows it to be retrieved by the viewer.

        session.setAttribute("ReportSource", reportSource);

    %>

  11. Create a viewer tag, specifying the viewer name, report source type, and report source variable.
  12. 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/