Jump to content
We've recently updated our Privacy Statement, available here ×

iReport bug: JRDataSource data ...


toolman

Recommended Posts

After an afternoon wrestling I have come to the conclusion that iReport has a bug with its internal datasource handling for custom implementations of JRDataSource.

 

I built a custom class, with a static method to return a new instantiation of the class. It correctly sets up in iReports datasource interface and 'test's OK, but when you try to build the report with iReport (PDF, JRViewer or any other) the custom class is not called and a single null row is returned on the output, not the x rows of the custom class.

 

Note: Jasper Reports happily works with the exact same JRDatasource class outside of iReport, so it must be something to do with iReport specifically, not jasper reports.

 

Luckily there is a simple workaround till this bug is resolved: make the custom class *also* implement JRDataSourceProvider, and make the "create" method return "this"

 

Try a trivial example and you'll find the same thing Im sure!

 

eg custom class:

 

 

Code:


public class TestGroupData implements JRDataSource, JRDataSourceProvider
{
int count = 0;

public Object getFieldValue(JRField field) throws JRException
{
String fieldName = field.getName();
if (fieldName.toString().equals("value"«»))
{
return new Double(10);
}
System.out.println("FALLTHRU" + fieldName);

return null;

}

public boolean next() throws JRException
{

count++;
if (count > 10) return false;

return true;
}

public static JRDataSource createDatasource()
{
System.out.println("instance!"«»);
return new TestGroupData();
}

public JRDataSource create(JasperReport report) throws JRException
{
return this;
}

public void dispose(JRDataSource dataSource) throws JRException
{
// TODO Auto-generated method stub

}

public JRField[] getFields(JasperReport report) throws JRException, UnsupportedOperationException
{
// TODO Auto-generated method stub
return null;
}

public boolean supportsGetFieldsOperation()
{
// TODO Auto-generated method stub
return false;
}


}

Post edited by: toolman, at: 2007/01/17 02:15

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...