pawel.silberring
-
Posts
3 -
Joined
-
Last visited
Content Type
Profiles
Forum
Events
Featured Visualizations
Knowledge Base
Documentation (PDF Downloads)
Blog
Documentation (Test Area)
Documentation
Dr. Jaspersoft Webinar Series
Security Advisories
Downloads
Posts posted by pawel.silberring
-
-
I had to create the complete data source code within the Jaspersoft Studio environment.
I use the Reporter in a larger project. so I wanted to integrate it into the environment of the project, but that turned out to be difficult.
What I do now is a minimal interface within Jaspersoft and from there, I use objects, which were created in my project. Here is my code:
import pJasperReport.JRTJasperReportTotals; // This is the link object to my project
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
public class TotalsTable implements JRDataSource {
JRTJasperReportTotals JRTaJRTJasperReportTotals = null;
String sTrace = "Init";
/**************************************************************/
public Object getFieldValue(JRField arg0) throws JRException {
// TODO Auto-generated method stub
String sResult = JRTaJRTJasperReportTotals.JRTGetField(arg0.getName());
return sResult;
}
/**************************************************************/
public boolean next() throws JRException {
boolean bResult = false;
if (JRTaJRTJasperReportTotals == null)
{
JRTaJRTJasperReportTotals = new JRTJasperReportTotals();
sTrace = JRTaJRTJasperReportTotals.JRTLoadTotals();
}
bResult = JRTaJRTJasperReportTotals.JRTNext();
return bResult;
}
/**************************************************************/
public static JRDataSource getDataSource()
{
return new TotalsTable();
}
}
I hope, this helps you a step forward.
-
I am new with JasperStudio 6.0.3. I am trying to implement a custom JRDataSource. I have created a class:
public class JRTJasperReportTotals implements JRDataSource
This class implements the next() and the getFieldValue() methods and contains a method:
public static JRDataSource getDataSource()
{
return new JRTJasperReportTotals();
}
The Class is then packed into a .jarWhen I create a new Data Adapter, this is how the Wizard looks like:
Pressing Test gives me:
What am I doing wrong here? Thank you in advance for any hint!
JRDataSource: Class does not return a datasource object
in Products
Posted
Hi,
the code above is some sort of a minimal interface, written within the environment of JasperReport. The object JRTaJRTJasperReportTotals is a class within my project and my minimal interface calls methods of this class with the same parameters and purpose. This allows me to program the more complex parts within my usual environment.
To make sure, this class is available for JasperReport, I create a .jar, which contains the object and put it into the directory of the Jasperreport files. Then I can start creation of the report:
JasperPrint aJasperPrint = null;
Exporter<ExporterInput, PdfReportConfiguration, PdfExporterConfiguration, OutputStreamExporterOutput> aExporter = null;
aJasperPrint = JasperFillManager.fillReport(sJasperReportFileName, aHashMap, new net.sf.jasperreports.engine.JREmptyDataSource() );
aExporter = new net.sf.jasperreports.engine.export.JRPdfExporter();
aExporter.setExporterInput(new SimpleExporterInput(aJasperPrint));
aExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(SRPsReportFileName));
aExporter.exportReport();
aHashmap is a map containing the parameters of my report.
Hope, that helps you a step forward!