Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » how to pass an object instance to ScriptedDataSetEventAdapter
how to pass an object instance to ScriptedDataSetEventAdapter [message #478721] Thu, 06 August 2009 14:26 Go to next message
Csaba  is currently offline Csaba Friend
Messages: 24
Registered: July 2009
Junior Member
Hello Guys,

I have a ScriptedDataSetEventAdapter subclass and I would like to hand
over a domain model object instance to that. I do the following:

IReportRunnable design = engine.openReportDesign(..);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.getAppContext().put("mykey", domainModelObjectInstance);
...

In the subclass:
public void beforeOpen(IDataSetInstance dataSet, IReportContext
reportContext) throws ScriptException {
super.beforeOpen(dataSet, reportContext);
Object myinstance = reportContext.getAppContext().get("mykey");
}

Q1)
Is this solution the right, standard way to do this?

Q2)
Shall I pass also the class loader of the object like this:
task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOA DER_KEY,
domainModelObjectInstance.getClass().getClassLoader());

Q3)
Perhaps should I use global (persistent) variable or some other method?

Thanks for the reply!
Re: how to pass an object instance to ScriptedDataSetEventAdapter [message #479409 is a reply to message #478721] Mon, 10 August 2009 22:20 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Csaba,

The method you have should work fine.

This line:
> task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOA DER_KEY,
> domainModelObjectInstance.getClass().getClassLoader());
sets the parent classloader to find additional classes(outside of the
report engine plugin) and should work if you set it to the classloader
of the class that is starting the engine, Which I assume has access to
your domainModelObjectInstance class.

Jason

Csaba wrote:
> Hello Guys,
>
> I have a ScriptedDataSetEventAdapter subclass and I would like to hand
> over a domain model object instance to that. I do the following:
>
> IReportRunnable design = engine.openReportDesign(..);
> IRunAndRenderTask task = engine.createRunAndRenderTask(design);
> task.getAppContext().put("mykey", domainModelObjectInstance);
> ..
>
> In the subclass:
> public void beforeOpen(IDataSetInstance dataSet, IReportContext
> reportContext) throws ScriptException {
> super.beforeOpen(dataSet, reportContext);
> Object myinstance = reportContext.getAppContext().get("mykey");
> }
>
> Q1)
> Is this solution the right, standard way to do this?
>
> Q2)
> Shall I pass also the class loader of the object like this:
> task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOA DER_KEY,
> domainModelObjectInstance.getClass().getClassLoader());
>
> Q3)
> Perhaps should I use global (persistent) variable or some other method?
>
> Thanks for the reply!
>
>
Previous Topic:oracle cache or BIRT caching?
Next Topic:pie chart bind to rows not columns?
Goto Forum:
  


Current Time: Sat Sep 21 03:05:39 GMT 2024

Powered by FUDForum. Page generated in 0.03608 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top