|
Re: Scripted Data Source and custom ODA data source: advantages and disadvantages [message #813950 is a reply to message #813380] |
Mon, 05 March 2012 21:51 |
|
Here is a very simple example of a Java Scripted Data Set:
package my.event.handlers;
import org.eclipse.birt.report.engine.api.script.IReportContext;
import org.eclipse.birt.report.engine.api.script.IUpdatableDataSetRow;
import org.eclipse.birt.report.engine.api.script.ScriptException;
import
org.eclipse.birt.report.engine.api.script.eventadapter.ScriptedDataSetEventAdapter;
import org.eclipse.birt.report.engine.api.script.instance.IDataSetInstance;
public class MyScriptedDataSetExample extends ScriptedDataSetEventAdapter {
@Override
public void beforeOpen(IDataSetInstance dataSet,
IReportContext reportContext) throws ScriptException {
}
@Override
public void open(IDataSetInstance dataSet) throws ScriptException {
}
private Integer cnt=0;
private Integer cntT=3;
@Override
public boolean fetch(IDataSetInstance dataSet, IUpdatableDataSetRow row) {
//dataSet.getInputParameterValue(arg0);
if( cnt < cntT){
try{
row.setColumnValue("col1", new Integer(cnt));
row.setColumnValue("col2", "hello");
cnt++;
return true;
}catch (Exception e){
}
}
return false;
}
}
Currently you implement these in a Java Project, jar it and put the jar
in the web-inf/lib. The only report specific thing is that in the data
set you have to specify the fully qualified class name to use. This is
done in the properties view under event handler for the data set.
On ODAs: These are generally preferable when you need to expose a gui
to another user or group of users.
Jason
On 3/5/2012 2:37 AM, Alexey Romanov wrote:
> I need to include BIRT reports in my RCP application. Since the data has
> to be retrieved by calling Java code, my options seem to be:
>
> 1) using Scripted Data Source written in Javascript
>
> 2) using Scripted Data Source written in Java
>
> 3) using an ODA extension
>
> In option 1) there is no type checking, so I'd prefer to avoid it.
> For option 2): are there good examples available (my googling only found
> Javascript examples)? Can I provide a Scripted Data Source in a separate
> OSGi bundle or does it have to be a part of .rptdesign/.rptlibrary?
>
> Option 3) looks more complicated, but doable.
>
> What other implications do these choices have?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03522 seconds