Hitachi Vantara Pentaho Community Forums
Results 1 to 1 of 1

Thread: Help with ExampleTableModel from tutorial

  1. #1
    Join Date
    Sep 2013
    Posts
    235

    Default Help with ExampleTableModel from tutorial

    Hi, I am working with 'Pentaho Reporting 3.5 for Java Developers' step by step.

    Can you please help me with some questions:
    for 'Chapter 5: Working with data sources' -
    I am trying to implement my own custom ExampleTableModel.

    I did all step as it was described, so I got for Chapter2SwingApp is excelent showing report with reflection call to "ch5.ExampleFactory#getAllData()" - method without parameters,

    ...but for "ch5.ExampleFactory#getLibData(true)" call - I got 'No such method: ch5.ExampleFactory#getLibData'

    How to solve it?

    PS Sorry, how can I change thread title? After publishing can't find an option for this. Sorry.

    for Chapter2SwingApp:

    Code:
    // load report definition
    ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
                
    URL url = this.getClass().getResource("/ch2/chapter2_report.prpt");
                
    Resource res = manager.createDirectly(url, MasterReport.class);
    MasterReport report = (MasterReport) res.getResource();
                
    NamedStaticDataFactory factory = new NamedStaticDataFactory();
    
    //commented code - 
    //factory.setQuery("default", "ch5.ExampleFactory#getLibData(true)");
    
    factory.setQuery("default", "ch5.ExampleFactory#getAllData()");
    report.setDataFactory(factory);
    then, for ExampleFactory -

    Code:
    package ch5;
    
    public class ExampleFactory {
        public ExampleTableModel getAllData() {
            return new ExampleTableModel();
        }
    
        public ExampleTableModel getLibData() {
            return new ExampleTableModel(true);
        }
    }
    and for ExampleTableModel:

    Code:
     
    ...
       public ExampleTableModel() {
            super();
            setDataVector(data, columnNames);
        }
    
        public ExampleTableModel(boolean libsOnly) {
            super();
            if (libsOnly) {
                Vector<Vector<Object>> vData = generateData();
                vData.remove(vData.size() - 1);
                vData.remove(vData.size() - 1);
                setDataVector(vData, getColumnNames());
            } else {
                setDataVector(data, columnNames);
            }
        }
    ...
    Last edited by Dzmitry; 09-19-2013 at 09:34 AM. Reason: change thread title

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.