Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Java method for generating reports using objects
sabu22
<p>Hi all,
I am facing an issue for generating reports using java objects. Actually i require help in creating a java method which will help me in generating reports with
java objects as an input.
I had done it previously using xmls as input to birt
The code is as follows:
public void generate(String xmlInput, String xsltInput)
throws BirtException, UnsupportedEncodingException,
TransformerException {
// open report design
this.setBirtEngine();
// open report design
design = birtEngine.openReportDesign(getClass().getClassLoader()
.getResourceAsStream(designTemplateName)); // The designTemplate is the rptdesign
// create task to run and render report
IRunAndRenderTask task = birtEngine.createRunAndRenderTask(design);
// Added for dynamic dataSource:Start
Map appContext = task.getAppContext();
String transformedApplicationXML = transform(xmlInput, xsltInput); //creating the xml source to pass in BIRT
appContext.put(
"org.eclipse.datatools.enablement.oda.xml.inputStream",
new ByteArrayInputStream(transformedApplicationXML
.getBytes("UTF-8")));
// Use closeInputStream (true) to let BIRT automatically close the
// inputStream.
appContext.put(
"org.eclipse.datatools.enablement.oda.xml.closeInputStream",
true);
// create task to run and render report
String pdfFileName = "Report" + ".pdf";
PDFRenderOption options = new PDFRenderOption();
options.setSupportedImageFormats("PNG;GIF;JPG;BMP;SWF;SVG");
options.setOutputFormat("pdf");
options.setOutputFileName(APPFOLDERPATH);
options.setOutputFileName(pdfFileName);
task.setRenderOption(options);
task.run();
task.close();
}
The above code uses xml as input to BIRT similarly i need to pass a java object to birt.
Any help is appreciated
Thanks</p>
Find more posts tagged with
Comments
kclark
<p>You want to use a pojo as a data source in your java code, correct?</p>
sabu22
<p>Yes i want to use pojo as a datasourse as well as i need to know how to construct a java method as i did above which will take input as java object and then generate a report.........</p><p> </p><p> </p><p>Thanks</p>