Implementing the Interactive Viewer

The Interactive viewer works almost exactly like the Page viewer. In fact, the Interactive viewer component derives from the Page viewer component, so it inherits all the base functionality. What it adds is a new toolbar button that enables an advanced searching User Interface inside the viewer. This is useful for larger reports and for end users requiring advanced searches where simple text string searching is not suitable. The Interactive viewer allows the report to be filtered using a specified record selection criteria.

Listing 32.8 shows a report being viewed by the Interactive viewer. Note that the setOwnPage method is called to indicate that the viewer owns the entire page, which is generally a good thing to do when using this viewer.

Listing 32.8. Using the Report Part Viewer in Code
//To create a Java interactive viewer you instantiate a
//CrystalReportInteractiveViewer object:
CrystalReportInteractiveViewer viewer = new CrystalReportInteractiveViewer();

//Set the viewer's report source by calling its setReportSource method
viewer.setReportSource(reportSource);

//Enable the Advanced Search Wizard.
viewer.setEnableBooleanSearch(true);

//Set the setOwnPage property to true. The setOwnPage property should always
//be set to true for the interactive viewer.
viewer.setOwnPage(true);

//After you have created and initialized a Java interactive viewer,
//you call its processHttpRequest method to launch it in a Web browser.

viewer.processHttpRequest(request, response, getServletContext(), null);

Figure 32.3 shows a report being displayed in the Interactive viewer and the advanced searching UI being used.

Figure 32.3. The Interactive viewer in action.


All viewers including the Interactive viewer share a number of toolbar elements. These properties can be programmatically toggled and are displayed in Table 32.2. All the viewer properties must be set before calling the ProcessHTTPRequest method that will display the selected report. For example, to ensure the Crystal logo is displayed when the involved report is viewed, the code line

Viewer.HasLogo(true);

Table 32.2. Toolbar Elements (Interactive Viewer)
PropertyProperty Description
HasLogoIncludes or excludes the “Powered by Crystal” logo when rendering the report.
HasExportButtonIncludes or excludes the Export button when rendering the report.
HasGotoPageButtonIncludes or excludes the Go to Page button when rendering the report.
HasPageNavigationButtonsIncludes or excludes the page navigation buttons when rendering the report.
HasPrintButtonIncludes or excludes the Print button when rendering the report.
HasRefreshButtonIncludes or excludes the Refresh button when rendering the report.
HasSearchButtonIncludes or excludes the Search button when rendering the report.
HasToggleGroupTreeButtonIncludes or excludes the Group Tree toggle button when rendering the report.
HasViewListSpecifies whether the viewer should display a list of previous views of the report.
SetPrintModeSet printing to use PDF or Active S printing (0=pdf, 1=actx).
HasZoomFactorListSpecifies zoom factor for displayed report.
HasBooleanSearchButtonIncludes or excludes the toggle Boolean search button when rendering the report. Unique to Interactive viewer.
HasHeaderAreaIncludes or excludes the header area when rendering the report. Unique to Interactive viewer.
HasPageBottomToolbarIncludes or excludes the page bottom toolbar. Unique to Interactive viewer.

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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.187.108