Best Practices


Although the makers of Crystal Reports have gone to great pains to develop an efficient product, there are things that you can do to improve performance. Here are examples of potential improvements.

When possible, always cache the report source in a session variable. This permits the report source to be used multiple times without having to create a new report source each time one is needed. In addition, caching enables reports to be quickly refreshed. Here s how to cache a report source:

 String report = "/reports/myReport.rpt"; 
JPEReportSource reportSource;
reportSource = new JPEReportSource(report);
session.putValue("reportSource", reportSource);

Set the OwnPage property to true if your JSP page contains only the viewer. This enables the viewer to completely handle the surrounding HTML content and reduces the amount of code that you need to include in your JSP application. This also enables the viewer to determine certain settings automatically.

For example, the viewer is able to choose the proper start and end page tags to use according to the device used to view the report page. The viewer also sets the content-type and charset information for the page, which is important if the report is displayed using international characters .

Also set the OwnForm method to true. This enables the viewer to handle state information automatically, which is used to perform client-side caching of information regarding the current state of the report.

Include the CrystalImageCleaner in your JSP application. The CrystalImageCleaner causes temporary files created by the viewer to be removed periodically. First import the CrystalImageCleaner, as shown here:

 <%@ page import="com.crystaldecisions.report.web.viewer.CrystalImageCleaner" %> 

Next, call the start() method. The start() method requires three arguments. The first argument is the Servlet context. The second argument is an integer that indicates how many minutes must pass before it searches for image files. The third argument is an integer that specifies the age the image file must be before it is deleted. The following example searches for image files every minute and deletes image files that are at least two minutes old.

 CrystalImageCleaner.start(getServletContext(), 60000, 12000); 

Call the stop() method to stop the automatic image cleanup. The stop() method requires one argument, which is the Servlet context shown here:

 CrystalImageCleaner.stop(getServletContext()); 



Crystal Reports 10
Crystal Reports 10: The Complete Reference
ISBN: B005DI80VA
EAN: N/A
Year: 2004
Pages: 223
Authors: George Peck

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