Understanding the Report Source


Because the Crystal Report viewer components are shared across both the Crystal Reports Server and the BusinessObjects Enterprise Professional/Premium editions, there must be a common interface defined so the viewer can display reports generated using both types of report processing engines. This interface is called the report source. The report source is an object that both the Crystal Reports Server edition and Professional/Premium editions supply that the viewer in turn communicates with to render the reports to the various forms of HTML.

There are two types of report sources, the Page Server and the Report Application Server. Each type of report source offers different advantages.

When to Use a Page Server

  • You want to take advantage of the Cache Server, so individual report pages are not generated every time they are requested.

  • Your application delivers reports that do not need to be changed at run-time.

When to Use the Report Application Server

  • Your application needs to modify reports at run-time.

  • Your application uses the DHTML Interactive viewer. The DHTML Interactive viewer requires the use of functionality only provided by the Report Application Server.

  • Your application uses the DHTML Grid viewer. Since the DHTML Grid viewer does not function with a Page Server, you need to use the Report Application Server when using the DHTML grid viewer.

The Java code in Listing 33.1 illustrates the first scenario where a report source object is obtained from the standalone Report Application Server.

Listing 33.1. Obtaining a Report Source from a Report File

//First you must create a new ReportClientDocument object ReportClientDocument reportClientDoc = new ReportClientDocument(); //After the ReportClientDocument is created, you then need to //specify the report file that is to be used as the report //source: String path = __ "C:\\Program Files\\Crystal Decisions\\Report Application Server" + " 10\\Reports\\Sample.rpt"; reportClientDoc.open(path, openReportOptions._openAsReadOnly); //Finally use the openReportSource method to return the report source object IReportSource reportSource = reportClientDoc.getReportSource();

Caution

All the code listings provided in this chapter are provided in JSP/Java. Although the .NET/COM and the Java flavors of the RAS SDK share identical functionality, there are obviously language nuances associated with each of them. Many code samples for additional language flavors are available for download from the www.usingcrystal.com website.


Listing 33.2 illustrates obtaining a report source when using the Report Application Server as part of BusinessObjects Enterprise. Notice that the same ReportClientDocument object is used. The difference is in how the ReportClientDocument object is obtained.

For more information on using the IEnterpriseSession as associated BusinessObjects Enterprise objects, p. 770.


Listing 33.2. Obtaining an EnterpriseSession Object

//Retrieve the IEnterpriseSession object previously stored in the user's session. IEnterpriseSession enterpriseSession = __ (IEnterpriseSession) session.getAttribute("EnterpriseSession"); //Use enterpriseSession object to retrieve the reportAppFactory object IReportAppFactory reportAppFactory = __ (IReportAppFactory) enterpriseSession.getService("", "RASReportFactory"); //Open the report document by specifying the report ID ReportClientDocument reportClientDoc = __ reportAppFactory.openDocument(reportID, 0, Locale.ENGLISH); //Finally use the openReportSource method to return the report source object IReportSource reportSource = reportClientDoc.getReportSource();

An alternative way to do this is shown in Listing 33.3.

Listing 33.3. Alternative Method to Obtain an EnterpriseSession Object

//Retrieve the IEnterpriseSession object. IEnterpriseSession enterpriseSession = __ (IEnterpriseSession) session.getAttribute("EnterpriseSession"); // Use the IEnterpriseSession object's getService method to // get an IReportAppFactory object. IReportSourceFactory reportFactory = \        (IReportSourceFactory) __ enterpriseSession.getService("", "RASReportFactory"); //Use IReportAppFactory object's openReportSource method, passing it //the report ID to return the reportSource object IReportSource reportSource = \        reportFactory.openReportSource(reportID, Locale.ENGLISH);

Listing 33.4 illustrates obtaining a report source object from the Page Server service from BusinessObjects Enterprise Professional/Premium.

Listing 33.4. Utilizing the Page Server to Open a Report

// Retrieve the IEnterpriseSession object previously stored in __ the user's session. IEnterpriseSession enterpriseSession =__  (IEnterpriseSession) session.getAttribute("EnterpriseSession"); // Use the getService method of the EnterpriseSession object to // obtain an IReportAppFactory object: IReportSourceFactory reportFactory = \        (IReportSourceFactory) __ enterpriseSession.getService ("", "PSReportFactory"); //Finally use the openReportSource method to return the report source object IReportSource reportSource =__  reportFactory.openReportSource(reportID, Locale.ENGLISH) ;




Crystal Reports XI(c) Official Guide
Crystal Reports XI Official Guide
ISBN: 0672329174
EAN: 2147483647
Year: N/A
Pages: 365

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net