Jasper Reports: JRBeanCollectionDataSource cannot be resolved to a type

后端 未结 1 730
情深已故
情深已故 2021-02-09 08:19

I\'m building a chart in iReports and when I compile in Eclipse I get the following error:

net.sf.jasperreports.engine.JRException: Errors were encountered whe         


        
1条回答
  •  悲哀的现实
    2021-02-09 08:27

    In the .jrxml the data source for the chart is defined as:

    
    

    This come from the iReports 4.7.0 autofill when you select Use datasource expression under Connection/Datasource exp in the details pane, the default expression from iReports is:

     new net.sf.jasperreports.engine.JREmptyDataSource(1)
    

    But this expression is wrong because .data is missing. It should read:

     new net.sf.jasperreports.engine.data.JREmptyDataSource(1)
    

    and then I changed the JREmptyDataSource(1) to JRBeanCollectionDataSource($F{chartData}) of course

    This fixes the compile time error and then I had to reorganize and redefine my Lists and POJO's so that I could easily access the data point pairs in my List of ChartData objects. Essentially this meant that instead of a single ChartData object with two lists of doubles (one for X-Axis and one for Y-Axis), I now have a list of ChartData objects, each with just one XY point. This seems to work well for now.

    0 讨论(0)
提交回复
热议问题