Implementing the Page Viewer


The first viewer component to be covered is the Page viewer, as illustrated in Listing 33.5. To use this viewer, you will create its CrystalReportViewer object. It, along with all the other viewers, exposes a method called setReportSource that accepts a valid report source object as obtained from the description in the previous section. Finally, again like the other viewers, it has a processHttpRequest method that accepts references to the current servlet context. This method does the actual rendering to HTML.

Listing 33.5. Viewing a Report over the Web

//To create a Java report viewer you need to instantiate a CrystalReportViewer //object. To create a CrystalReportViewer object: CrystalReportViewer viewer = new CrystalReportViewer(); //Obtain a ReportSource object. Set the viewer's report source __ by calling its //setReportSource method. viewer.setReportSource(reportSource); //When you have created and initialized a Java report page viewer, __ you call//its processHttpRequest method to launch it in a web browser. viewer.processHttpRequest(request, response, getServletContext(), null);

Figure 33.1 shows the output of this code.

Figure 33.1. A report being displayed in the DHTML Page viewer.


All viewers including the DHTML Page viewer share a number of toolbar elements. These properties can be programmatically toggled and are displayed in Table 33.1. All the viewer properties must be set before calling the ProcessHTTPRequest method that displays the selected report.

Table 33.1. Toolbar Elements (DHTML Page Viewer)

Property

Property Description

HasLogo

Includes or excludes the Business Objects logo when rendering the report.

HasExportButton

Includes or excludes the export button when rendering the report.

HasGotoPageButton

Includes or excludes the Go to Page button when rendering the report.

HasPageNavigationButtons

Includes or excludes the page navigation buttons when rendering the report.

HasPrintButton

Includes or excludes the Print button when rendering the report.

HasRefreshButton

Includes or excludes the Refresh button when rendering the report.

HasSearchButton

Includes or excludes the Search button when rendering the report.

HasToggleGroupTreeButton

Includes or excludes the Group Tree toggle button when rendering the report.

HasViewList

Specifies whether the viewer should display a list of previous views of the report.

SetPrintMode

Set printing to use PDF or Active X printing (0=pdf, 1=actx).

HasZoomFactorList

Specifies zoom factor for displayed report.


For example, to ensure the Business Objects logo is displayed when the involved report is viewed, the code line

Viewer.HasLogo(true);


needs to be included in the code before the processHTTPRequest method is called.

As the different viewers are introduced and discussed later in this chapter, some additional elements pertinent to the viewer being discussed will be displayed in that section's table.




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