Integrate report into your application

You have used the Business Application Modeler to generate your data source library. You now need to integrate this library into your existing application.

Each of the demo applications that highlight a generated data source include an application node named RunReportFromApp. This node includes code that provides a working example of how to use the data source generated by the Business Application Modeler in your bespoke applications. At a high level, the application does three things:
  • Establishes a connection.
  • Creates a report.
  • Views the report.

Establish a connection

For this application, the connection creates a database connection to the officestore SQLite database. The details for the connection are hard-coded in the sample application.

Create a report

In the Java sample application, look for the createPDFReport method.
  1. Configure the report.

    Java example:

    FormatHandler handler = new FormatWriter(reportFile);
    PDFRenderer renderer = new PDFRenderer(handler);
    FourRpLayouter report = new FourRpLayouter(reportDesignFile, renderer);

    C# example:

    FormatHandler handler = new FormatWriter(reportFileName);
    LayoutedPagesConsumer renderer = new PDFRenderer(handler); ;
    PXMLConsumer layout = new PXMLLayouter(renderer);
    FourRpProcessor reportProcessor = new FourRpProcessor(reportDesignFileName, layout);
  2. Instantiate the data source object from the data source library.

    Java/C# example:

    // Run the report
    OrderReport orderReport = new OrderReport(connection);
  3. Pass the object to the report engine for processing.

    Java example:

    report.runFromJAXBObject(orderReport);

    C# example:

    reportProcessor.runFromSerializable(orderReport);

View the report

The viewReport method opens and displays the created PDF file.