Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Looking for java formatting

  1. #1
    Join Date
    May 2008

    Default Looking for java formatting

    Hi, I am setting up a demo for consideration of this tool in an application, and have it working fine in the java application. I am trying to find examples on formatting the pdf document, doing groupings and subreporting in java (not the designer and not xml) using the api but can't find anything informative. Does anyone have pointers to where to find java source examples for implementing from this point?

    common report generator class.method:
    JFreeReport report = ReportGenerator.getInstance().parseReport(reportFile);
                TableDataFactory factory = new TableDataFactory("default", tableModel);
    ... looking for examples on adding groupings of data, etc to the report
    one business service report template where I want to add formatting, layout, data groupings...looking for examples in java
     protected TableModel getTableModel(List dataset){
     Vector columnNames = new Vector();
            columnNames.add("..many column names");
            Vector rows = new Vector();
            for (Object obj : dataset) {
                 MyBusinessObj obj = (MyBusinessObj) obj;
                Vector row = new Vector();
                row.add(..obj data);
            return new DefaultTableModel(rows, columnNames);
    Last edited by hedelson; 05-18-2008 at 04:05 PM.

  2. #2
    Join Date
    Mar 2003


    Have a look at our demo-code. The demos contain serveral reports that are defined using only the API.

    And then of course, make sure you have either the code or the javadocs at your side. Our code actually contains a lot of documentation which explains the less obvious cases. However, in most cases, looking at one or two of the API-demos should be enough to get you up and running.

    You should also be aware that the reporting engine itself does not perform any sorting. Sorting is part of the data-preparation, and therefore the data you pass into the engine must be sorted to match the grouping definitions or your results might look a bit funny.

    However, you can also use a hybrid approach, where you parse a report-template from an XML file and then reconfigure the report as needed. I usually prefer this approach to the "completely-from-scratch" approach, as this way you can define the common elements in XML using the report-designer to change it later, while still having the flexibility to customize the parsed JFreeReport object later.

    For getting data into the engine, I would suggest you implement your own factory so that you can make use of parameters. The table-datafactory is a primitive thing that will not be useful in subreport-scenarios (as it is basically a Hashmap, so it maps queries to tables, and ignores all parameter information). Implementing your own factory is easy, especially as you already seem to have the code that produces the TableModels. Have a look at the DataFactory interface to get started.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.