Prev | Current Page 690 | Next

Frank Zammetti

"Practical DWR 2 Projects"

That object contains all the information we need to
get a connection to the database, and that??™s precisely what is done next.
After that comes the actual report generation code. Using DataVision is a piece of cake.
First, a Report object is instantiated. We then hand the database connection we just created to
it. Next, we get a StringReader on the string containing the report??™s XML. After that, we ask
the Report instance to read the XML using an InputSource. After that, a new StringWriter is
instantiated, which is where our output will wind up. Then, we set the desired layout engine,
which is what DataVision uses to generate our output. In this case, we??™re using the CSSHTMLLE
layout engine, which generates HTML using CSS (there is a plain HTMLLE layout engine as well
that uses a table-based approach . . . the CSS-based engine produces results that are generally
better). Finally, a call to the runReport() method of the Report object actually runs the report
and writes the output to the StringWriter. All that??™s left is to return a String version of that
StringWriter. Also note the finally block that cleans up the database connection, which is
nothing out of the ordinary for JDBC programming.


Pages:
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702