DELIVER DYNAMIC AND INTERACTIVE WEB CONTENT IN J2EE APPLICATIONS Florin Stoica "Lucian Blaga" University of Sibiu, Faculty of Sciences, Computer Sciences and Economic Informatics Department, Romania e-mail:
[email protected] Reporting is the process of accessing data, formatting it, and delivering it as information inside and outside the organization. It serves as the foundation of broader business intelligence strategy by providing the most-requested pieces of information reliably and securely. The advent of the Web has provided yet another medium to distribute information and with it developers are faced with a variety of challenges in getting actionable information into the hands of end users in a consumable format, as quickly as possible. We focus on J2EE applications because J2EE application servers provide a baseline of functionality that makes it easy to develop distributed business components, and assemble them into robust and functioncomplete business solutions that perform well and are highly scalable.
1. INTRODUCTION Publishing data to an web site should be quick, requiring minimal code and providing rich functionality for the end user. It should offer: • Rich, presentation-quality information with minimal coding. • Total integration of content into the web site via flexible customization. • Full interactivity to empower end users to get the exact information they require by viewing current reports, modifying reports, scheduling new ones, using parameterized reports, and exporting to a variety of formats. In this paper, we discuss our experience with integrating Business Objects reporting products with Sun J2EE Application Server 1.4 Developer Release. These products include: • Crystal Reports - an intuitive reporting toolkit for creating flexible, feature-rich reports and tightly integrate them into web (and windows) applications. • Crystal Report Application Server - a common architecture for data access, reporting, and information delivery in a dynamic manner with interactive suport. The goal of this paper is to help others evaluate the benefits of using Crystal Report Application Server in the context of a J2EE application.
2. JSP vs. CRYSTAL REPORT Java Server Pages is one of the most popular technologies for publishing interactive content, primarily because it is: • Familiar – JSP technology have been widely adopted by the Java community. • A standard – JSP is a specification, not a product. Because many vendors are competing to provide tools for JSP developers, it is more likely that the standard will endure. • An effective division of labor - JSP technology provides a separation between markup language and programming language code. Typically, page authors define the user experience using markup language. Java developers develop Servlets to handle input processing, and EJB’s to define the business logic. Using Crystal technology offers all of the benefits of JSP at a fraction of the time and cost: • Presentation-quality, interactive reporting – Work within an intuitive object-oriented designer interface to create reports as interactive documents with drilldown, charts, maps, alerting, parameter prompts, hyperlinks, personalization and much more. Report designer supports the creation of virtually any report, style or format required: a cross tab, invoice, order form, etc. Formatting using fonts, lines, graphics and freeform layouts is available at the click of a button or wizard using Crystal. • Leverage familiar standards – Leveraging common web standards, including DHTML, XML, JDBC and EJB’s, Crystal technology complete control over all aspects of content generation, integration and system functionality. • Fully customizable – Powerful customization features and full support for standard scripting languages allows developers to rapidly build tailored web applications. • Virtually no code required – With the ability to manipulate data into groups, summarize it, sort and filter, developers can focus on more difficult project components, such as business logic. • Parameterized reporting to more complex sorting, filtering, summarizing, maps and charting. • Built-in navigation tools including table of content, hyperlinks, drill down and searching. • Exports to Adobe Acrobat (PDF), Microsoft Excel and Word (RTF) and native Crystal Reports format. Publishing data using JSPs is typically accomplished by hand-coding the static and dynamic content. In many ways, a “complex” report that includes the above
functionality becomes an application in its own right. This approach can became problematic for a number of reasons: • The implementation effort for reports with grouped data proved to be prohibitive. • We had no practical way to rapidly prototype reports. • Maintenance became very time-consuming. • Customization of the output of the reports for specific uses (e.g. printing, exports) is time-consuming (or almost impossible). Crystal also includes page-on-demand report processing technology. It breaks down each report into individual pages, sending the requested individual pages - and not the entire report - down to the browser. Page-on-demand also supports job sharing: reports are cached and the above individual pages can be resent instead of hitting database again to regenerate data. This technology minimize the number of queries to the underlying database resulting in higher performance for the end user, less bandwidth and less hardware costs. 3. REPORT APPLICATION SERVER ARCHITECTURE This section describes the Report Application Server (RAS) components. The RAS is in itself a client/server system and is composed of two basic components: the RAS server, and an SDK that provides an interface to the server (figure 3.1). The web container manages communication between the web browser and the RAS SDK. Web Browser
Web Container RAS SDK
RAS Server Fig. 3.1 Report Application Server basic components
The RAS server provides the services for building and customizing reports. In this sense, it forms the server part of the client/server system. The server handles report documents using the Crystal Reports Print Engine (CRPE). The RAS SDK is composed of a number of Java packages, which contain interfaces and classes for communicating with the server. Essentially, the packages divide the interfaces and classes into functional areas. The RAS SDK is the client part of the
client/server system. and is implemented using a Model-View-Controller architecture. The following diagram presents a high-level view of the packages and some key controllers in the RAS Java SDK. This diagram represents controllers, object models, and the view component. ReportClientDocument Controllers (application package) DatabaseController
ReportDefController
DataDefController
RowsetController
View selection
ReportClientDocument
Modify data in the model (a report document) Model (core functional areas) data package definition package
and update RAS Server
View (Report Viewer)
Other packages document
lib
exportoptions
Query / M odify a report document
Fig. 3.2 RAS Java SDK Architecture
The object models are used to define the content in a report document. They contain the data structures necessary to determine the view of the objects in the report document. The object models are implemented in two main libraries: • The data package provides a definition for the report’s database and data. • The definition package determines the appearance and layout of the report objects that appear in a report document. The controllers are defined in the application package. They possess the logic to modify the object models on the client side. Although the object models provide functionality to manipulate the data and report definition, they do not synchronize the data that client is manipulating with that on the server. In order to properly modify a report document and ensure that the RAS server is updated, must be used the appropriate controller.
The client documents are the report documents that the RAS SDK creates and modifies. These report documents are managed by the the ReportClientDocument object which controls the way that report documents are handled. It is the central point from which all other libraries in the SDK derive, and it enables accessing either the controllers (to modify or extract data), or the object models (to access data). Effectively, it allows to open, modify, and save reports. Finally, the view, provides a particular view of the data in the model. Each view may access the data in the model directly or by using a controller. In order to modify data the model, it is necessary to use a controller. There are three thin client DHTML Report Viewers: 1. Crystal Reports Viewer (provides basic web reporting viewer capabilities). 2. Crystal Reports Interactive Viewer (provides all the capabilities of the Java Report Page Viewer, plus the ability to do a Boolean search on the current report). 3. Crystal Reports Parts Viewer (provides the ability to view individual report parts - charts, text, or fields). 4. WEB REPORTING USING RAS SDK This section provides some sample examples of how to use some of the basic functionality of the RAS SDK to display a report, modify data definition (a formula field) and change data source at runtime. Example 4.1: View a report using Crystal Reports Interactive Viewer (complete code). Simple Preview Report
Example 4.2: Change a formula definition at runtime (partial code). ClientDocument
ReportClientDocument getDataDefController()
DataDefController getDataDefinition()
IDataDefinition
getFormulaFieldController()
FormulaFieldController
Fig. 4.1 Object M odel Diagram for example 4.2 (change a formula definition)
Example 4.3: Change a data source at runtime (partial code). ClientDocument
ReportClientDocument getDatabase() getDatabaseController()
IDataBase DatabaseController
Fig. 4.2 Object M odel Diagram for example 4.3 (change data source)
5. INTEGRATION WITH SUN J2EE APPLICATION SERVER 1.4 In order to make RAS SDK packages available to J2EE Server, we must copy all jar archives from :\Program Files\Common Files\Crystal Decisions\2.0\jars (where denote partition where Crystal RAS was installed) to a subdirectory (for example: jars) of directory where J2EE Server was installed. After that, we add all these packages in JVM Settings -> Path Settings including -> Classpath Suffix. Next step is to modify security.policy of default domain, for allowing RAS to acces report documents from deployed applications. In this file must be added (for example): grant codebase "file:${com.sun.enterprise.home}/jars/-" { permission java.security.AllPermission; }; Next step, in RAS Configuration Manager must specify Report Directory as \domains\domain1\applications\j2ee-apps, where is directory where J2EE Server was installed. The Report Directory setting specifies which folder the Report Application Server has access to (would allow access to the specified folder and all sub-folders). Finally, we must copy the directory:
:\Program Files\Common Files\Crystal Decisions\2.0\crystalreportviewers as \domains\domain1\docroot\crystalreportviewers. The next image presents a report document delivered by Report Application Server and displayed in Crystal Reports Interactive Viewer:
Fig. 5.1 Report Application Server & Crystal Reports Interactive Viewer in action
6. CONCLUS IONS The combination of the Report Application Server (RAS) and the RAS SDK provides the ability to easily deliver rich, actionable content on the Java development platform. Capabilities of the SDK include creating reports on the fly, opening existing reports, adding and removing sections, fields, charts, and many other report elements, manipulating report parameters and formulas, and applying design templates to produce richly formatted reports. In web-based applications, the SDK resides on the application server, however all processing is delegated off to the Report Application Server to process. This Server can reside on the application server, but can also be offloaded to a dedicated report processing server.
The SDK is fully supported for use in Java Server Pages (JSP), Servlets, and Enterprise Java Beans (EJBs) and provide tight integration with J2EE. There are also a set of server-side report viewer components included. These interactive components render the report to pure HTML format, meaning that end users require nothing more than a standard web browser to view reports. This zero-client delivery reduces IT headaches by eliminating client-side control installation. An important benefit provided by Crystal technology is the decoupling of report design from application development. Often, a developer can delegate report content design to a business analyst. Compared to JSP-coded reports, Crystal technology simplifies the entire report creation and publishing process, and data is delivered to the Web much more faster. REFERENCES [1] Bruce Eckel, Thinking in Java, 3rd Edition, Prentice-Hall, 2002 [2] Inderjeet Singh, Beth Stearns, Mark Johnson, Enterprise Team, Designing Enterprise Applications with the J2EE Platform, Second Edition, AddisonWesley, 2002 [3] Bill Sheldon, Crystal Enterprise - A report server solution, http://www.businessobjects.com/products/dev_zone/default.asp [4] Business Objects, Enterprise Reporting brochure, http://www.businessobjects.com/products/reporting/default.asp [5] Business Objects, Crystal Enterprise datasheet, http://www.businessobjects.com/products/reporting/default.asp [6] Ben Forta, Edwin Smith, Roger Kerr, JavaServer Pages, Teora, 2002 [7] Crystal Decisions, Report Application Server Java SDK Guide, 2002