|
Re: how to pass an object instance to ScriptedDataSetEventAdapter [message #479409 is a reply to message #478721] |
Mon, 10 August 2009 22:20 |
|
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!
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03608 seconds