I tried reading your code to better understand which columns you want, but without context, I have no idea. All bean are pojo, with private fields and public getters and setters.
Assuming there is no grouping, and essentially each ScenarioLoadModel will correspond to one line in the report, you will get a bean as follows:
public class ScenariaResults { private String id; private String name; private String load; private int passCount; private int failCount; public ScenariaResults(String id, String name, String load, int passCount, int failCount) { super(); this.id = id; this.name = name; this.load = load; this.passCount = passCount; this.failCount = failCount; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLoad() { return load; } public void setLoad(String load) { this.load = load; } public int getPassCount() { return passCount; } public void setPassCount(int passCount) { this.passCount = passCount; } public int getFailCount() { return failCount; } public void setFailCount(int failCount) { this.failCount = failCount; } @Override public String toString() { return "ScenariaResults [id=" + id + ", name=" + name + ", load=" + load + ", passCount=" + passCount + ", failCount=" + failCount + "]"; } }
So, basically in the code you have above, you create instances of ScenarioResults and add them to the list. Once you have a list, all you have to do is create a JRDataSource:
List<ScenarioResults> dataBeanList = ...call your method to get the list of results
Now that you are designing a report in iReport, it can be a little difficult to get the automatically imported fields. Basically, first add your project using bean to the class path in iReports (you can simply point it to the bin folder or jar file): Tools β options β classpath tab. Now, to add fields, follow these steps:
- Click the following icon:

- Select the
JavaBean Datasource tab. - Enter the class name of your bean. (e.g.
ScenarioResults ) - Click
Read attributes - Highlight the required fields in the report and click
Add Selected Field(s) . - Click
OK .
Now, if you want to check how a report with data looks, and not just an empty data source, Factory comes here. It is intended for testing only when using iReport. You need to create a class that essentially creates a dummy dataset for you. It should look something like this:
import java.util.ArrayList; import java.util.List; public class ScenarioResultsFactory { public static List<ScenarioResults> createBeanCollection() { List<ScenarioResults> list = new ArrayList<ScenarioResults>(); list.add(new ScenarioResults("1", "test", "load", 10, 5));
Now you need to create a data source pointing to it in iReport.
- Next to the Datasource drop-down list in the toolbar, click the icon using the `Report Datasources.
- Click
New . - Select
JavaBeans set datasource . Click Next . - For the name, enter
ScenarioResultsFactory . - For the Factory class, you need to put the class name, including the package. Therefore, if the class is in the
com package, you should have com.ScenarioResultsFactory here. - For the static method, set
createBeanCollection if it does not already exist. - Check the
Use field description box. Click Test to verify that it worked. - Click
Save .