anette.engel Posted August 3, 2018 Share Posted August 3, 2018 I have inherited code in our application which generates Jasper Reports. I want to create a new report with a custom data source. To test the report I want to create custom data adapter which returns mock data. For advice I looked at (and related articles)https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-user-guide/v630/working-jrdatasource-interfaceI created a very simple data adapter (see below). When creating the new data adapter I try testing the new data apater by clickin on "test" but I get a class not found exception. I noticed that within the Data Adpater Wizard it is possible to add jar files. This option isn't really practical during development for me. Is it not possible to configure my workspace, project or JasperStudio to find the class in my project? Please note I don't have a JasperStudio project. Is this required? It would make things a bit complicated since classes and Jasper Reports files are in an existing project.Does anyone know how to create and successfully use a custom data adapter to test the report design with Eclipse in the Report Designer View?Thanks,Anette import net.sf.jasperreports.engine.JRDataSource;import net.sf.jasperreports.engine.data.JRBeanArrayDataSource;public class MySampleDataSourceFactory { public static JRDataSource createStaticDatasource() { final TestBean testBean = new MySampleDataSourceFactory.TestBean(); testBean.setFirstname( "Grommit" ); testBean.setLastname( "The Dog" ); final TestBean[] data = new TestBean[1]; data[0] = testBean; return new JRBeanArrayDataSource( data ); } public static class TestBean { private String firstname; private String lastname; public String getFirstname() { return this.firstname; } public void setFirstname( final String firstname ) { this.firstname = firstname; } public String getLastname() { return this.lastname; } public void setLastname( final String lastname ) { this.lastname = lastname; } }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now