JReport is Java-centric object-oriented reporting tool written entirely in Java. We provide bean components, so that you can easily incorporate JReport in your own applications. JReport beans can be used inside IDE tools like JBuilder, Visual Café, Visual Age, and SilverStream. Additionally, please consult the next chapter, "Using JReport Beans in Forte™ for Java" for special instructions on using JReport beans in that IDE. Combining the power of JReport bean APIs, and the reusability of the JReport beans, you will not need to open JReport GUI each time to run, print, or diagnose the problems of the report.
Altogether, we provide the following beans or API:
- JReport Design API - Design reports programmatically (for each report design command and operation).
- JReport Catalog API - Modify or create a catalog programmatically.
- JReport Engine Bean (JREngine) - Run report result, export the result to multiple file formats (e.g. PDF, HTML, RTF) and to a printer.
- JReport Result Viewer Bean (JRResultViewer) - Show the report result file, export to multiple file formats and a printer.
- JReport Design Bean (JRDesign) - Load the visual report design environment for modifying a report.
- JReport Catalog Bean (JRCatalog) - Manipulate and access the catalog of JReport.
Detailed descriptions of each will follow later in this chapter.
JReport Engine Bean provides a programming API to the report running and exporting process. JReport Engine is mainly responsible for fetching data qualified from the data source and returning the result to JReport.
Briefly, JReport Engine Bean enables the user to:
- Run the result for a pre-developed report
- Assign new values for the pre-defined objects in the report, and then run the result with the new values. These objects include parameter, whereportion, data driver, connection and others.
- Export the report result to multiple file formats (HTML, PDF, XLS, RTF, Postscript, Text, CSV, Applet, Email) or a printer.
When you install JReport Designer, JReport Engine Bean will be installed at the same time. After installation, you should have the main components as below:
lib\JREngine.zip* - Archive file for JReport Engine Bean.
bin\report.ini* - Configuration file.
lib\log4j-1.2.8.jar* - Jar file used for JReport Engine logging system.
lib\JimiProClasses.zip - Non-GUI Engine class library, please append this to the classpath besides JREngine.zip.
lib\resource.zip - Resources of JReport Designer.
lib\xerces.jar - Jar file used when exporting to xml.
lib\JRResultViewer.zip - Archive file for JRResult Viewer Bean.
lib\JRResultViewer.jar - Jar file for JRResult Viewer Bean.
lib\chart.jar - Jar file used when exporting to html with images to be embedded as a chart applet in the html file.
lib\udo\udo.ini - Register of user defined objects.
lib\activation.jar - Jar file used when exporting to mail.
lib\mail.jar - Jar file used when exporting to mail.
lib\Itext.zip - Archive file used when exporting to PDF.
lib\poiHSSF_151.jar - Jar file used when exporting to Excel.
Readme.txt, License.txt - Information about release.
help\pro-material\TestEngineBean.java, TestWherePortion.java, LocalWherePortion.java, TestSunVMMPValue.java, - simple test programs to demonstrate how to call and use JReport Engine Bean. Or you can find them on our Web site at http://www.jinfonet.com/webpage/kbase/kbase.htm for the manual related materials.
Note: The asterisk * for the first three means that when you call JReport Engine Bean, these three files must be used.
Before calling JReport Engine Bean, you must make sure that:
- Because the only archive file for JReport Engine Bean is JREngine.zip. You need to set the CLASSPATH environment variable before you compile and run the program. Append the following string to the CLASSPATH:
- Beginning with Build 569, before you call the methods for exporting a report to Mail, PDF, Excel or XML format, you should add the corresponding class files or jars with valid path in your classpath.
a. Mail: mail.jar and activation.jar
b. PDF: Itext.zip
c. Excel: poiHSSF_151.jar
d. XML: xerces.jar
- When you set the report home in the bean, JReport will get information from the file report.ini under %ReportHome%\bin and check whether they are valid by setting runtime key in the bean. Open report.ini, you will find the configuration information, including the temp path, template path and the help path. JReport Engine Bean will use the temp path to export the temporary files. Therefore, make sure the temp folder specified in report.ini exists.
When you only use the JReport Runtime instead of JReport Designer, you should deploy Engine Bean Runtime components which include the following files:
JREngine.zip - JReport Engine Bean
JRResultViewer.zip - Result Viewer Bean
JRResultViewer.jar - Result Viewer Bean in jar
log4j-1.2.8.jar - Jar file used for JReport Engine logging system
chart.jar - Chart applet
udo.ini - Register of user defined objects
report.ini - Configuration file
activation.jar - Used when export to mail
mail.jar - Used when export to mail
- report.ini - In your code if you set the reportHome "c:\\jreport", we will read the file report.ini under the directory c:\jreport\bin. You will find in this file the configuration information, including the temp path, template path and the help path. JReport Engine Bean will use the temp path to export the temporary files. Therefore, you should ensure there exists the temp folder specified in the file report.ini.
- If you only want to generate a report, you need only JReport Engine Bean, while if you want to view the report result file, you will use JReport Result Viewer Bean. Of course, you will need both beans if you want to accomplish your goals of generating and viewing reports in one instance of a class.
JREngine Bean has following properties. All the data types of the properties are of Java strings. These properties are listed below:
- UID - The JReport run-time user ID.
- key - The JReport run-time key.
- reportHome - The home path where the report.ini and other JReport system files exist.
- reportName - 'The report name which the engine will run.
- catName - The name of the catalog which contains all the required objects used in the report.
- paramValues - The string containing the parameter values, separated by comma (',').
- paramFile - The name of the parameter value file. This will be ignored if paramValues is specified.
- resultFile - The name of the result file.
The following methods are used for value assignment to the above properties:
- setKey ("key")
- runReport( ) or runReport(boolean genRst)
- UID - The JReport run-time User ID.
- Key - The JReport run-time Key.
- HomePath - The installation path for JReport Designer. Strictly speaking, if you set the HomePath as "c:\\jreport", then the first thing JREngine will do when running the report is to check jslc.dat and report.ini files under c:\jreport\bin to see whether they are valid.
- reportName - A string which contains both report path information and the report name.
- catName - A string which contains both catalog path information and the catalog name. The report path and the catalog path may be different.
- ValuesString - The string to assign new value for the parameter used in the current report. The parameter should be the one defined in the catalog.
- ParamFileName - The name of the parameter value file. This will be ignored if paramValues is specified.
- ResultFileName - The name of the result file. If you want to generate the report result file (with .rst extension), then set the result file name (.rst extension) with full file path. For example, setResultFile("c:\\temp\\test.rst"). The resultFile contains both the path and the file name information. If there is no path specified, the current path will be used. If there is no file name specified, the reportName will be used (with the .rst extension).
- Beginning with Version 4.0, when you call JReport Engine Bean in your application program, your run-time user ID and run-time Key are needed.
- The method runReport ( ) will have the same effect as setLoadReport ("yes"). setLoadReport ("yes/no") is the method in the last Engine Bean version.
- When JReport Engine Bean runs out the report result, it will generate the .rst file first. But you may want to run the report result out and then export to other formats like html, pdf without gnerating any .rst file. Now, we support this feature. runReport( ) and runReport(true) are equivalent, and we will always generate the .rst file. But if you hope not to generate .rst file, please call runReport(false), this way we will print, output the report result without getting out the .rst file and the performace will be improved also.
- If more than one parameter is needed in the report, you can pass multiple parameters in the paramValues string. The ValuesString format is: paraName1=paraValues1, paraName2=paraValue2 where the paraName1 and paraName2 are the parameter names and paraValue1 and paraValue2 are the values. The comma is the separate operator, and the equal sign is to separate the parameter name and parameter value. If the parameter name or parameter value contains the separate operator -- comma or equal sign, it needs escape. We provide the the escape operator -- \\. If your put the escape operator before the separate operator, we will not treat it as the separate operator. For example:
* the parameter string is: "param1=aaa\\,aa,param2=bbbbb,param3=ccccc", this parameter string will be parsed to
the value for param1 is aaa, aa
the value for param2 is bbbbc
the value for param3 is ccccc
* the parameter string is: "pa\\=ram1=aaa\\,aa,param2=bbbbb,param3=ccccc", this parameter string will be parased to
the value for pa=ram1 (name) is aaa, aa (value)
the value for param2 is bbbbb
the value for param3 is ccccc
The format of the parameter file is: one parameter name-value pair will take one line, another parameter name-value pair will start from a new line. Each line is formatted as paramname=paramvalue, and we also provide the escape for equal sign same as above.
Note: you do not necessarily set all parameters value, and default value will be used for the parameter whose value is not set here. If you do not set a parameter value, JReport will use the default value for this parameter.
- If you want to know the report's parameters without running reports, call the method getReportParams(). This method will return a vector and each element of this vector is jet.formula.ParamDesc. The class ParamDesc has five public properties:
name - Parameter name, this property is String type.
type - Parameter type, this property is String type.
promptText - Parameter prompt text, this property is String type.
value - Parameter value, this property is String type.
isColumn - Indicate whether this parameter must be a DB column name or a boolean type. If this parameter is a DB column name, this parameter's value must be an available group field. You can call method getAvlGroupFields(), this method will return a vector which contains all the available group fields. Please be noted, if more than one parameter is DB column name, the values of these parameters can not be the same.
Import the classes of JREngine Bean by adding the following import statements at the beginning of your program. The first import statements bring into the bean class;
Then, we will create an instance. To report with JREngine Bean, you should create an instance of JREngine Bean first.Note: From version 4.0, when you call JREngine Bean in your program, you should set your user id and key of JReport Runtime.
bean = new JREngine();
//From Version 4.0
bean.setUID("JReport Runtime User ID");
bean.setKey("JReport Runtime Key");
After the object is created, set the report home, report file, catalog file, result file (if necessary), parameter values (if necessary).
Note: You could run or export a self-contained report by calling JReport Engine Bean. Suppose you want to run a self-contained report "customerlist.clx" which was saved under c:\jreport\demo\reports, you do not need to set the catalog name in your code, you could just set the report home, report file, show debug and error information (if necessary), log file (if necessary) as below:
bean.setShowInfoLevel( bean.vDebug | bean.vError );
For more information about Self-contained Report, see User's Guide | JReport Designer Window | Main Menu.
Reference Note: JReport Enterprise Server User's Guide | Clients Accessing JReport Enterprise Server | Report.
With JREngine Bean object, you can manipulate and access many reports. You never need to create a bean for each report. There are a lot of useful methods provided in JREngine Bean, and you can call them before/after runReport() method.
The two properties showInfoLevel and logFile are used for controlling debug, error and other information displayed. The following two methods are used to set values to these properties:
- setShowInfoLevel (vDebug/vError/vOff)
- setLogFile ("LogFileName")
- vDebug, vError and vOff are used for showing debug information, error information and turning off debug and error information.
- LogFileName specifies where the debug, error and other information will go. LogFileName contains both the path and the file name. If no path is specified, the current path is used. If no file name is specified, the file jreport.log is used.
The method getStatus() returns a message about the status after runReport() in JReport Engine Bean is called. If it is applied earlier, it will only return "No report load" for that the method just stores static value. The getStatus () method may return one of the following messages:
- "Error: Cannot find the resource file JRsIndex.jrc!". This is caused by the incorrect setting of the report home path.
- "Error: Cannot open the catalog "Catalog Name"!". The JREngine cannot open the given catalog file.
- "Error: Cannot open the report "Report Name"!". The JREngine cannot open the given report file.
- "Error: Cannot open the parameter file "Parameter file name"!". The JREngine cannot open the given parameter file.
- "Error: Unknown format in Parameter values!". The parameter values string has the wrong format.
- Other errors. JREngine bean encountered other exceptions.
There are also several methods with which JReport Engine will export the result file (with the .rst extension) to different file formats (HTML, PDF, TEXT, XLS, PS etc.). The example program TestEngineBean.java will demonstrate how to use them. One method can be implemented by using different parameters. For more information about it, please refer to the JReport Java doc.
Note: The method
exportToHtml(java.lang.String htmlFileName)will take the method
exportToHtml(java.lang.String htmlFileName, boolean bChartApplet, boolean isMultiFile, boolean bUsingTable, boolean bHyperlink, boolean bPageNum, boolean bAbsolute, int iBrowser)using the default parameter values like this:
exportToHtml("HtmlFileName", false, true, false, true, true, true, JREngine.IE).
Before the method exportToMail is called, the mail server should be configured with the following method:
configMailServer(String SMTPServerIP, String MyMailAddress, int SMTPServerPort)
SMTPServerIP is the mail server IP address
MyMailAddress is the sender's mail address
SMTPServerPort is the mail server port
- The method
exportToText(java.lang.String textFileName, boolean isNormalText)will take the method
exportToText(java.lang.String textFileName, boolean isNormalText, boolean isRepeat, char delimiter)using the default parameter values like this:
exportToText( "TextFileName", isNormalText, false, ' ').
- The method
exportToText(java.lang.String rstFileName, java.lang.String textFileName, boolean isNormalText)will take the method
exportToText(java.lang.String rstFileName, java.lang.String textFileName, boolean isNormalText, boolean isRepeat, char delimiter)using the default parameter values like this:
exportToText( "ResultFileName", "TextFileName", isNormalText, false, ' ').
If you want to export the report result to fax, please download the files listed in the tables below from the web site http://java.sun.com/products/javacomm/index.html, and put them in the specified locations first (on Windows):
File Name Location comm.jar
There are four methods provided for printing the report:
- printReport ( )
- printReport (Object printJob, Object pageFormat, boolean bInteractive, boolean bInBackground, boolean bUseJDK11)
- printReport (Object printJob, Object pageFormat, boolean bInteractive, boolean bInBackground, boolean bUseJDK11, boolean bSeparateLargePage)
- printReport (Object printJob, Object pageFormat, boolean bInteractive, boolean bInBackground,
boolean bUseJDK11, boolean bSeparateLargePage, String jobName)
- printReport (Object printJob, Object pageFormat, boolean bInteractive, boolean bInBackground,
boolean bUseJDK11, boolean bSeparateLargePage, String jobName, String printer)
- printReport(java.lang.Object job, boolean bInteractive, java.lang.Object pf, boolean bInBackground, JReportPrintListener jreportprintlistener, int useJDK, java.lang.String jobName, java.util.Vector attributeInfo, java.lang.String printer)
- getPrintStatus ( )
- printJob -- The job of this printing.
- pageFormat -- Description for the size and orientation of a page to be printed.
- bInteractive -- A boolean value. If you set it to false, the print setup dialog will not show up.
- bInBackground -- A boolean value. If you set it to true, the printing dialog will not show up.
- bUseJDK11 -- A boolean value. If you set it to true, it will use JDK1.1.x to print the report. Otherwise if you set false, it will use the JDK which you are running to print the report. The JDK 1.1 printing method is quick in speed but the printing quality is not guaranteed. The JDK 1.2 method can give you a satisfactory result, even for a gif file, but it is slow in speed.
- bSeparateLargePage -- A boolean value, if the report page size is larger than the print paper size, and you want to separate the large report page during printing, you should set this property to true. If the print page size which you choose is less than the report page size, then the report will be printed as multiple pages serially, this means we will separate the large page of the report automatically. After you set it to true, for JDK1.2 or higher, the page format dialog will be popped up. In this dialog, you can choose the page format which you want to print with, we will use this page size for printing. For JDK1.1.x, however, you must change the page format which you want to print with in the print dialog (click the property button, then choose the page format).
- jobName -- A String value of the job name. When printing, the job name you defined will list in the window which shows information, such as the status of documents and the owner of a document etc.
- printer -- The name of the printer used to print the report. Please note that if you set bUseJDK11 to be false, you can't set printer but use the default printer only.
- job -- The print job of this print action. It is a instance of PrintJob or PrinterJob.
- bUseJDK -- An integer value. If you set it to 0, it will use JDK1.1 to print the report. If you set it to 1, it will use the JDK1.2, which you are running to print the report. If you set it to 2, it will use the JDK1.4, which you are running to print the report. The JDK 1.1 printing method is quick in speed but the printing quality is not guaranteed. However, The
JDK 1.2 method can return you with satisfactory result, even for a gif file, but it is slow in speed. JDK 1.4 provides more options to do print such as specifying the paper tray.
- attributeInfo -- A vector whose elements are string.
Each string has defined in interface PrintConfig.Interface PrintConfig located in package jet.bean. For example,you can implement PrintConfig and call its fields like this:
- The first method printReport ( ) is called to start printing. It will take the third method using the default parameter values like this:
printReport(null, null, true, false, false, false)
- The second and third method allows you to pass the parameters -- printJob, pageFormat, bInteractive, bInbackground, bUseJDK11 and bSeparateLargePage.
- The third printing method (with the bSeparateLargePage parameter) is not recommended, it may cause some unexpected errors, for example, you may get an extra blank page.
- After printing is started, the method getPrintStatus ( ) can be used to get the print job status. Returned values of getPrintStatus ( ) are:
"No print job"
"No report load"
Other error messages if there are errors.
Example1: Under JDK1.2 or higher, if you use JDK1.2 printing method (boolean bUseJDK11), you can call the printReport method like this:
PrinterJob printJob = PrinterJob.getPrinterJob();
bean.printReport(printJob, printJob.defaultPage(), false, false, false);
Or, if you do not want to getPrinterJob, simply call:
bean.printReport(null, null, false, false, false);
Example2: Under JDK1.2 or higher, if you use JDK1.1 printing method, you are best recommended not to getPrintJob, just call:
bean.printReport(null, null, false, false, true);
Example 3: Under JDK 1.2 or higher, if you use JDK1.1 printing method and select a network printer, you can call the printReport method like this:
bean.printReport(null, null, false, false, true, false, "job1", "\\\\GUOF\\HP LaserJet 6L Pro PCL5e");
Example 4: Under JDK 1.2 or higher, if you use JDK1.1 printing method and select a local printer, you can call the printReport method like this:
bean.printReport(null, null, false, false, true, false, "job1", "HP LaserJet 6L Pro PCL5e");
Also JReport Engine provides the methods to add, delete, save and get a new WHERE portion in the catalog. Please note that the the join relationships of tables will remain in the new where clause. By specifying the name of the WHERE portion, you can pick it out from report catalog and bind it up with the current query:
- setNamedWherePortion(queryName) - Set a named WHERE portion from the catalog to the query of the current report. If this WHERE portion can not be found in the catalog, return to the "false".
- setWherePortion(WherePortionString) - Set the WHERE portion in the string format to the query of the current report.
- saveWherePortion(queryName, WherePortionString) - Save the WHERE portion in string format with the specific query name in report catalog.
- deleteWherePortion(queryName) - Delete a specific WHERE portion from report catalog, update and save the catalog after deletion.
- getAvailableQueryFields() - Get the available query fields from the query for the current report. This will return an enumeration of the names of fields, formulas and parameters and their corresponding data types which will be needed to build up the WHERE portion and validate the condition.
- getAvailbleWherePortions() - Get an enumeration of the names of all the WHERE portions saved in the report catalog.
- SaveCatalog() - Save the current catalog. Return to " true" if successfully saved.
- queryName - The name of the WHERE portion in SQL query.
- WherePortionString - The string of the Where Portion.
The setDataDriver() method is used to specify the user data source driver. JReport can use user data source driver as the data source of a report. By default, JReport uses JDBC connection. Only when the report works with the user data source can users call this method.
Note: This method is mutually exclusive with the method of setResultSet(). Users can only use one of them at the same time.
- setDataDriver(String dataDriver)
- dataDriver - The URL specifying the User Data Source, for example "jrquery:/AddressListDataSource;c:\AddressList.txt"
The setResultSet() method is used to set the cached query result to work with JReport. When this method is called, JReport will load the specified cached query result and generate reports with data from the cached query result.
Note: This method is mutually exclusive with the method of setDataDriver(). Users can only use one of them at the same time.
- setResultSet(String cachQueryResultSetFile)
- cachQueryResultSetFile - The full file path of Cached Query Result, for example "c:\myresult"
JReport products support the National Language feature. If you specified to apply NLS, when you design and save the report, the language-dependent text of Label object will be extracted to a resource file(.properties). Copy the resource file for another language and modify the text in the file. When JReport is running, JReport Engine will retrieve the language-dependent text according to the current locale, the end user will get a report result that matches his locale setting.
- setLocale(Locale currentLocale)
- setEncoding(String encoding)
- At run time, you can specify the encoding and Locale for rendering the report result accordingly. But please make sure that when you design the report, you have set it to support NLS and have made the property file for the language you hope to apply.
- In addition, we also provide the following method that might be very useful.
Vector getAvailableLocales(String clt)
This method will get all of the Locales that current report supported. The parameter clt is current client's Locale. If clt is in current report Locales it is moved to the index at zero.
The Communicator here is a class defined by JReport. This method will launch to run JReport Engine Bean, but do not save to the result file. It returns the Communicator of this report.
You are recommended to use this method in JReport Engine Bean and setCommunicator() in JReport Result Viewer Bean. That is,
resultViewerBean.setCommunicator( engineBean.getReportCommunicator() );
- modifyUserInfo(String strUserName, String strPassword)
Obviously, this method is to modify user's information: user ID and password.
- setConnection(String strURL, String strUID, String strPSWD, String strJdbcDriver)
- setConnection(String strURL, String strUID, String strPSWD, String strJdbcDriver, boolean fetchSupportInfo)
- String strURL - The URL of the database. For the format of the URL please refer to the instructions of your JDBC driver.
- String strUID - The user ID for the driver.
- String strPSWD - The user's password for the driver.
- String strJdbcDriver - The full qualified name of class. The class is responsible for connecting to the database and fetch the data. For example, com.sybase.jdbc.SybDriver or oracle.jdbc.driver.OracleDriver. If not specified, the default one will be used.
- boolean fetchSupportInfo - Set true to get the user support information in DBMS. This method will only work when the user has set the connection object or url.
This method enables users to set the connection information before running the report. You can let the user specify the user id and the password before running a report to ensure the security. Another application of this method is that readers can select a different database before running reports, so they can see different report results. Of course, usually in this case, the two databases have the same structure and this will ease the work of building another catalog.
For example, this method may be called like this:
- setUserResultSet(java.sql.ResultSet userResultSet)
- userResultSet - The JDBC ResultSet object created by the user. Users should release it by themselves.
This method is used to set the result set required to run the report.
For example, this method may be called as below:
Statement stmt = connection.createStatement();
ResultSet rs = stmt.getResultSet();
- String getVersion()
This method will get the version number of your Engine Bean.
Example: you can use this method like below:
bean = new JREngine();
Then the method will print out:
JReport Engine Bean version : 3.1.1; Build Number : 512; Help Version : 505
The Help version is the matched help version number of the current engine. The two may be different.
- getPageOrientation ()
The method getPageOrientation is used for getting the orientation of the report page. You should call this method after calling runReport method. The return value is an int value, and it can be LANDSCAPE or PORTRAIT. If it is -1, it makes no sense, say you may have called it before calling runReport method, which is wrong.
The method is used to get the information of all DBFields in the Detail section, including DBFields in the Detail section of the subreport which is inserted in the Detail section. The method returns a vector which contains name, type and SQL type of DBFields.
Note: The method will return DBField information whatever the Detail section is invisible or suppressed.
The method is used to get the information of reports, including record number, total page number, print time, username.
Note: Before this method is used, method runReport( ) or loadReport( ) should be called first.
The above method checks whether the current engine is single-threaded. The returned value is of boolean type. If the current engine is single-threaded, it will return true, otherwise false.
- setSingleThread(boolean single)
The above method can be set to to run the engine with a single thread. It is specially used in the environment like EJB which only allows single thread when doing any transactions.
- single - set to true if to use single-thread, otherwise, we will use the default multi-threaded engine.
Beginning with version 4.0, when you call JReport Engine Bean in your application program, your user ID and runtime Key are needed.
- getUID( )
Get and return the JReport Runtime UserID.
- setUID(String uid)
Set the JReport Runtime UserID to call the JREngine.
Get and return the JReport Runtime key.
- setKey (String key)
Set the JReport Runtime key.
- uid - the JReport Runtime User ID.
- key - the JReport Runtime key.
After you installed JReport Engine Bean, you will find the illustrative test programs under %installroot%\help\pro-material. Or you can go to our web site at http://www.jinfonet.com/webpage/kbase/kbase.htm for the manual related materials.
TestEngineBean.java - a test program. Let us explain how TestEngineBean.java works, and how it uses the methods provided by JReport Engine Bean mentioned above. First, the example file TestEngineBean.java contains some hard-coded paths. These must be modified before they can be compiled and run. For example, assuming JReport Designer is installed under d:\jreport, then the "Test A" section can be modified to the following:
The result file will be saved under the d:\jreport\temp directory and the result file name will be GroupingWithFormulas.rst. In addition, TestEngineBean.java will also show how to use JReport Engine to export result file (with the .rst extension) to different file formats (HTML,PDF,TEXT,etc.). Assuming the GroupingWithFormulas.rst has already been generated by JREngine, now we export it to different file formats:
d:\\jreport\\temp\\... is the location where users specify the new generated files. At last, TestEngineBean.java will call the methods to add, delete, save and get the WHERE portion in the report catalog:
bean.saveWherePortion("condition2","@\"Customers_Customer ID\" < 20");
bean.setWherePortion("((@\"Customers_Customer ID\" > 10) and (@\"Customers_Customer ID\" < 20))");
To run the TestEngineBean.java, use the following command to compile the test program first:
javac -classpath d:\JReport\lib\jrengine.zip;d:\JReport\lib\log4j-1.2.8.jar; TestEngineBean.java
Here we assume d:\JReport is the place where JReport Engine is installed and it is the current directory when users execute these commands. Finally, the test program can be run with the following command:
java -classpath d:\JReport\lib\jrengine.zip;d:\JReport\lib\log4j-1.2.8.jar; TestEngineBean
When the test program is complete, you will note a temporary file <reportname>.rst. In this test program, this will be either customerlist.rst or phaseorder.rst depending on which report has been executed. These result files can be read and displayed by either JReport Viewer (the thin client viewer) or JReport Result Viewer Bean.
TestWherePortion.java - A test program purely for the method operated on WHERE Portion. You can add, save and delete new WHERE portion just like what we do in TestEngine.java. The difference is that the user can do all these things in his own report home, catalog and the report file. These result files can be read and displayed by either JReport Viewer (the thin client viewer) or JReport Result Viewer Bean.