Skip to main content
Windward

Basic Programming Example

engine-wiki-logo.pngOverview

This section takes you through a basic example of embedding the Windward Java Engine. Once the Java Engine is embedded into a Java software application, you can generate reports and documents.

Details

The Windward Java Engine is a set of JAR files. Your application accesses it through one basic class. This basic class is subclassed for each output format, as each format has its own options that you can set.

You must add all of the JARs in the Windward "jars" folder as libraries to your project.

Source Code

The Java Engine takes two input streams, the template and the data, and creates an output stream – the final report.  Our first program we are going to write a method that is passed the three streams. 

This example creates a PDF report using and XML data source and default settings.

import net.windward.datasource.dom4j.Dom4jDataSource;
import net.windward.xmlreport.ProcessPdf;
import net.windward.xmlreport.ProcessReport;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * Generate a PDF report using an XML file as the datasource. For this use case this is the entire set of code needed
 * to use Windward Reports. For different output formats and/or different datasources, the code will change.
 */
public class GeneratePdfReport {
 /**
  * Generate a PDF report using an XML file as the datasource.
  * @param template The report template.
  * @param report The generated report.
  * @param xmlData The XML data file.
  */
 public static void generatePdfReport(InputStream template, OutputStream report, InputStream xmlData) throws Exception {
  // generally called once when your app starts, not in here.
  ProcessReport.init();
  // create the report.
  ProcessPdf proc = new ProcessPdf(template, report);
  proc.processSetup();
  proc.processData(new Dom4jDataSource(xmlData), "");
  proc.processComplete();
 }
}
  • Was this article helpful?