|
|
Re: birt List java bean as dataSource [message #799227 is a reply to message #798581] |
Wed, 15 February 2012 16:15 |
|
Yes. Before you run the report load the records field into the app
context like:
task.getAppContext().put("myrecords", records);
The report can then be written to use a scripted data source
http://www.eclipse.org/birt/phoenix/examples/scripting/scripteddatasource/
to read the values. In the scripted data set open method your can get
access to the records like:
myrecords = reportContext.getAppContext().get("myrecords");
You should then be able to use the fetch method to iterate over myrecords.
Jason
On 2/14/2012 4:33 PM, zubin Mising name wrote:
> Hello,
>
> Is there any way to use a java.util.list as dataSource that pass in to
> birt?
>
> for example following are the code to export pdf format out:
>
> public byte[] createPDF(final IReportRunnable design, List<Map<String,
> Object>> records) throws Exception {
> PDFRenderContext renderContext = new PDFRenderContext();
> HashMap contextMap = new HashMap();
> contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,
> renderContext);
> HTMLRenderOption options = new HTMLRenderOption();
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> options.setOutputStream(out);
> options.setOutputFormat("pdf");
>
> IRunAndRenderTask task = birtEngine.createRunAndRenderTask(design);
>
> task.setAppContext(contextMap);
> task.setRenderOption(options);
> task.run();
> task.close();
> return out.toByteArray();
> }
>
>
> task.close();
> return out.toByteArray();
>
>
> records is the list of result that should use as datasource. is there a
> way to do it in birt.
>
> thanks
|
|
|
Powered by
FUDForum. Page generated in 0.03324 seconds