JReport and SilverStream Application Server Integration Notes

Jinfonet Software, Inc.

March, 1999

 

Introduction

This note describes the integration between JReport products and SilverStream Application Server 2.0.  Please note that only JReport Server 1.2 and a special version of JReport Viewer 1.2 are compatible with Microsoft Java VM and this SilverStream.  Do not use JReport version 1.1.4 for this purpose.  The Integration can occur in two ways: client/server and desktop.  We assume that SilverStream users are using a Client/Server architecture.  Therefore only the Client/Server approach is described below.

We assume that you will first use JReport Professional Designer to design the reports.  Next, you install JReport Server on a computer designated as a "server" with TCP/IP connectivity and copy the entire report catalog directory to that computer.  Finally, you integrate the JReport Client Viewer Bean into a SilverStream application and use JReport Server to generate the reports.

How JReport works

The JReport system is used for design, view and deploy formatted reports from data retrieved from either a JDBC or ODBC connection or from the user's application data.

While using the JReport system,the first step  is to design your reports by using JReport Designer.  JReport Designer must run under a Java VM (Sun's JDK 1.1.7 or JDK 1.2) which supports a Java compiler to process the formulas in the report.   (This is required even if you don't use formula in your report.  Since Microsoft's Java VM does not provide a Java compiler, so it cannot be used to run JReport Designer. In the next release, we will provide our own formula compiler and make the JReport Designer also compatible with Microsoft Java VM.) 

For the step-by-step illustration of how to install the JReport Designer, please refer to the tutorial http://www.jinfonet.com/help/lesson1.htm.   After the reports being designed and tested, they are saved in the files with the extension .cls.  (Optionally a source/specification file with the extension .rpt may be generated.)   To see how to use JReport Designer to design a simple report, please refer to http://www.jinfonet.com/help/lesson2.htm

The saved reports then can be deployed by using JReport Server and Viewer Bean.  The report engine (JReport Server) runs on a server computer and communicates with the report viewer (Client Viewer Bean) through the HTTP protocol.   You will first copy all the files in the report catalog directory to the server computer.  Some of the files you will copy are:

Before the catalog and its reports can work on the server computer, you need to make sure that the database connection is properly setup.   JReport Catalog Doctor packaged with JReport Server is provided for setting up the database connection inside the catalog.  For how to use JReport Catalog Doctor, please refer to: http://www.jinfonet.com/help/CatDr_UserGuide.htm

JReport Client Viewer Bean is used to issue requests to JReport Server to run a particular report on the server.  After running a report, JReport Server creates a result file with extension .rst.  This result file will be sent to the client computer and viewed by JReport Client Viewer Bean which is integrated as a part of your SilverStream application.

How to integrate JReport Client Viewer bean into SilverStream

In order to run JReport Client Viewer bean in SilverStream, JReport Server should be loaded first.  To find out how to install and run JReport Server, please refer to: http://www.jinfonet.com/help/lesson5.htm.

In the followings, we assume that you have already started JReport Server on a server computer.

Setting up the JReport Viewer Bean

The first thing you need to do is to download the jrviewer116.zip file from Jinfonet's web site. Inside this zip file, there are several jar files that contain the JReport Client Viewer beans. Unzip this file to a directory where you want to install the JReport Client Viewer beans.   Note that because of the special way, SilverStream uses the HTTP protocol and here   the viewer bean  is a special version designed to work with SilverStream.  Do not use the viewer beans that come with JReport Server.  They will not work for SilverStream.

Integrating JReport Client Viewer beans into SilverStream

The first step to integrate JReport Client Viewer bean into SilverStream is to load SilverStream Server and SilverStream Designer:

Inside the SilverStream Designer, select a database that you want to use, click on the Media icon and  the new icon at the bottom of the right part of the window and select Upload Media Object.  The following Open Media File Dialog will pop up:

ss1.jpg (75337 bytes)

 

ss2.jpg (42607 bytes)

Select OneStepJRViewer.jar or TwoStepsJRViewer.jar (the files you have just unzipped from jrviewer116.zip) and click the Open button.

Note: One step client viewer bean will pop up a dialog to get the value for any parameter required for a report.  Two step client viewer bean however, gives the user program the control to obtain the parameters and pass them to the bean.   In the first step the bean supplies information about the parameters and in the second step the parameters are sent to the bean and the report is run.  If the user program already has the parameter information, then it is possible to just use the second step calls.

Once the Jar file containing the bean has been selected, the file is analyzed and loaded into the database as a Java bean. The bean can then be accessed via the Form Designer.  For this example, select OneStepJRViewer.jar.

Click the Form icon in the SilverStream Designer window, then click the New icon at the bottom to create a new form. Click Cancel when asked to select a primary table.  (You can also select an existing form as the starting point.)  The Form Designer window will now pop up:

ss3.jpg (83829 bytes)

ss4.jpg (87415 bytes)

ss5.jpg (75139 bytes)

ss6.jpg (79186 bytes)

  • Add a button into the form.  Double click the button to pop up the Programming Editor and click the Java button. In the method actionPerformed(), insert the calls to the client viewer bean's methods.  For our example, add the following to the program.  (We assume JRDirectViewer is the client viewer bean you inserted and of course, you should use the IP number of your computer as the ServerName.  If you wish to see how the one step client viewer bean handles the parameter, select "invoice" for the ReportName.)
  •                JRDirectViewer.setServerName("204.177.148.110");
                  
    JRDirectViewer.setPort("8888");
                  
    JRDirectViewer.setCatName("SunVMDemo");
                  
    JRDirectViewer.setReportName("lesson3");
                  
    JRDirectViewer.setLoadReport("yes");

    If ServerName, Port, CatName and ReportName have already been set in the property List (see the previous step), you only need to call JRDirectViewer.setLoadReport("yes") to run the report.

    To test what we have designed so far, click Enter Test Mode button in the toolbar.  In the test mode, click the button you added and you should be able to see the result of the report.

    ss7.jpg (115997 bytes)

     

    How to use JReport the html page property

    Using Page Designer, you can create a html page.

    In SilverStream Designer, Click the Pages icon,

    ss8.jpg (84512 bytes)

    then click the New icon at the bottom to create a new page. You can also select an existing page as the starting point.  The Page Designer window will now pop up:

    In Page Designer window, you can create a URL link which refer to JReport Server,

    ss9.jpg (20302 bytes)

    the URL format like this:

    http://204.177.148.110:8888/jreports/tutorial/invoice.cls?catalog=Tutorial&
    report=invoice&result_type=1&Submit_Btn=Submit

    Note: result_type=1 means generate html format report. Detail information see the lesson5.html

    ss10.jpg (77711 bytes)

    To test what we have designed so far, click Show page in browser button in the toolbar.  The Internet Explorer browser will be run and the html page you have been designed will be shown.

    ss11.jpg (40962 bytes)

    Click the URL link the html result of report will be shown.

    ss12.jpg (77879 bytes)

     

    Using SilverJRunner to access to JReport Server

    You can also access to JReport Server using SilverJRunner on a Client and Server basis. 
    Load SilverStream Server and SilverStream Designer, and make a form named cltviewer based on jinfonet database in SilverStream Designer.  In this form, add client viewer bean, and set all properties needed as above(assume the JReport Server have been installed, you can install JReport Server on any machine including the machine that installed SilverStream),

    ss13.jpg (87369 bytes)

     

    After making a form, then install SillverJRunner to a machine, you can use this machine as client  to access to SilverStream Server.  Type the following command in DOS command(you can find silverjrunner.exe in bin directory under SilverStream Server's setup directory):

        silverjrunner test jinfonet cltviewer

    We assume test is the machine in which you installed SilverStream Server, jinfonet is the database name in SilverStream Server, cltviewer is the form name that you maked in jinfonet database.

    After you run silverjrunner, you can see the following:

    ss14.jpg (35795 bytes)