<= Previous | Next => | Table of Contents | DataVision FAQ |
What do you mean by "Web application"? If you are asking, "can I run DataVision from a Java application that happens to have a Web component?", then the answer is yes. See Can I run DataVision from a Java application? for instructions. See also the answer to the question Can DataVision read data from anywhere else?.
To modify DataVision to work as an applet would take a bit of reworking. All file access (report XML files, parameter files, and layout engine output) would have to be modified to fit in the sandbox security model or be eliminated. Using the report design aspects of DataVision would be nigh impossible, as they assume a multi-window GUI.
You could run report files retrieved from a server and display the HTML results without too much effort by modifying or replacing either the HTML or Swing layout engine. If your reports had parameters, you would have to ask the user for the parameter values first (say, via a Web form), store the values in a temporary parameter XML file, then feed that file to the report object. See How do I ask the user for parameters?.
Yes. You need to instantiate a Report object and have it read the XML file and possibly a parameter value XML file, then give the report object a layout engine object (such as LaTeXLE).
Here's how you would do it:
Report report = new Report(); report.setDatabasePassword("mypassword"); report.readFile(xml_file_name); // Must be after password if (there_are_params_in_report) { // This must come after reading the report file report.setParameterXMLFile(param_xml_file_name); } report.setLayoutEngine(new LaTeXLE(a_writer)); // ...or HTMLLE, or SwingLE, or any other layout engine // Finally, run the report either in a separate thread or in // the current thread. Pick one of the following two. report.run(); // Run the report in a separate thread. // Doesn't wait for this thread to finish // (code left as an exercise for the reader). // or report.runReport(); // Run the report in this thread
Finally, you must include in your classpath two JAR files that come with DataVision: DataVision.jar and MinML.jar. MinML is the XML parser written by John Wilson.
There are two ways a report gets parameter values: either by asking the user or by reading a parameter XML file. If you want the user to be prompted for input, you should not give the report a parameter file name. Instead, you should tell the system that you want to use a Swing window to prompt the user for parameter values by using the following code some time before running the report:
ErrorHandler.useGUI(true);
When a report runs, it asks itself, "Do I have any parameters that need values?" If the answer is yes, it then asks itself, "Am I using a GUI?" If the answer to that question is "yes", it opens a Swing window to ask the user for parameter values. If the answer is "no", it reads the parameter XML file you gave it.
To specify a parameter file on the command line, use the -r command line option. See Running DataVision from the Command Line in the Users' Manual for details.
To specify a parameter's value within your code, you need to ask the report object to find it and then set its value.
// Ask the report to find the parameter for you Parameter p = report.findParameter(new Long(myParamID)); // or p = report.findParameterByName("My Parameter Name"); // Set the parameter's value. This sets a single value. p.setValue(0, "The New Value"); // To set more values (if it is a range or a list of values), keep // calling setValue(). // p.setValue(1, "Another Value");
Now, the tricky part: telling the report that it does not have to read a parameter XML file or ask the user for values. My untested suggestion: create a subclass of Report and override askForParameters. In that new method, set the parameter values and then tell the report that you are done.
protected void askForParameters() { // Ask the report to find the parameter for you Parameter p = findParameter(new Long(myParamID)); // Set the parameter's value. This sets a single value. p.setValue(0, "The New Value"); // The next two lines are necessary. askedForParameters = true; parametersHaveValues = true; }
The Report.run method runs the report in a new, separate thread. The Report.runReport method runs the report in the same thread from which it is called. (All run does is create a new thread and tell it to run runReport.) If you have written code like this:
public static void main(String[] args) { Report report = new Report(); // ... report.run(); // WRONG; new thread can't run }
then the report will quit immediately because you have not waited for the newly spawned thread to finish running the report. If you want to wait for the report to finish, use runReport like this:
public static void main(String[] args) { Report report = new Report(); // ... report.runReport(); // CORRECT; waits until finished }
If DataVision keeps asking you for your password over and over again, that is because it was not able to connect to the database sucessfully. Your password could be correct but the connection info string could be wrong.
Hitting "Cancel" will stop the insanity. If no other reports are already open, DataVision will quit.
The way this works will change in the future: you will be shown the error messages and will be able to open the database connection info dialog from the login dialog.
Note: as of DataVision v0.4.2, this problem should no longer happen. Printing from DataVision should no longer throw an exception.
Some Linux users started seeing exceptions while trying to print reports from the Swing report window. They were seeing the message "java.awt.image.ImagingOpException: Unable to transform src image". These users were all using Java 1.4.
Aditya Gilra (aditya_gilra@yahoo.com) did some research, and reports: "I had the same problem with j2sdk 1.4 beta 1. I had a look at the bug reports at java.sun.com and found that there are two types of printing bugs.
"1. j2sdk 1.4 beta has this printing bug because it cannot parse the output of lpstat which has changed in RHL 7.1. This has been corrected in the latest version which I downloaded and datavision works fine now.
"2. However if a printer has a special character _,& etc. java will ignore that printer. Hence make sure that there is no special character in the name of the printer queue."
In summary, the fix is to get the latest version of Java.
Unfortunately, some drivers do not support the optional driver features upon which earlier versions of DataVision relied. As of version 0.2.0, DataVision uses only the basic JDBC features common to all drivers.
The rest of this answer only applies to version of DataVision before 0.2.0. If you see an error message something like this (when running DataVision from the command line):
Exception occurred during event dispatching: java.lang.AbstractMethodError at jimm.datavision.Report.run(Report.java:763) at jimm.datavision.gui.ReportRunner.run(ReportRunner.java:37) at jimm.datavision.gui.DesignWin.runReport(DesignWin.java:709) at jimm.datavision.gui.DesignWin.actionPerformed(DesignWin.java:618)
then your driver does not support one of the new driver calls used by early version of DataVision. Try to upgrade to a newer version of your driver or a newer version of DataVision. For example, one user saw this message until he upgraded to version from MM.MySQL 2.0.4 to 2.0.11.
The latest version of the MySQL JDBC driver is available on the MySQL driver SourceForge project page.
On some Linux systems (for example, Red Hat 7.x), when you start DataVision a whole slew of identical error messages are generated that look something like this:
Font specified in font.properties not found [--symbol-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific]
These error messages are harmless. There is at least one way to get rid of them: edit the file $JAVA_HOME/jre/lib/font.properties and replace all occurrences of "-adobe-" with "-urw". Note that you may need to be root to edit this file.
Tom Van Overbeke (tom.van.overbeke@pandora.be) describes another way to get rid of the messages: "I checked all the fonts.dir available on my system, there were a dozen of them. then I grepped through all of them to check for "standard symbols l", and i found the entry in the file /usr/share/fonts/default/Type1/fonts.dir. The entry was:
s050000l.pfb -URW-Standard Symbols L-medium-r-normal--0-0-0-0-p-0-urw-fontspecific
"and I changed it to:
s050000l.pfb -URW-Standard Symbols L-medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
"Then I quit X, stopped and restarted xfs and restarted X, and it worked."
<= Previous | Next => | Table of Contents |