Java Object in Chart Scripts [message #244312] |
Fri, 22 June 2007 11:29  |
Eclipse User |
|
|
|
Originally posted by: justin.tradingmetrics.com
How can you make a java object visible to a chart script?
addScriptableJavaObject doesn't seem to do the trick.
|
|
|
|
|
|
|
|
Re: Java Object in Chart Scripts [message #244664 is a reply to message #244395] |
Mon, 25 June 2007 15:13   |
Eclipse User |
|
|
|
addScriptableObject is deprecated, but you can register it in the appContext
of IReportContext. To access it in a chart script, if you use
IChartScriptContext.getExternalContext().getScriptable(), it will return you
an instance of IReportContext
So something like this should work:
function beforeGeneration(chart, icsc) //any chart script function here
{
icsc.getExternalContext().getScriptable().getAppContext().ge t( "variableName");
}
Thanks,
David
context.getScriptable().get
"Justin" <justin@tradingmetrics.com> wrote in message
news:e2b72acee7f5ad0d819598ef581dd3da$1@www.eclipse.org...
>I found that method but couldn't figure out how to use it from the
>documentation (or even the type it's supposed to return or from where.)
>
> Could you tell me how to do that? If I called addScriptableJavaObject(
> myObject ) does that mean that it is already in the context?
>
> If not, how do I put it there?
>
> If so, how do I access it?
>
> Justin
>
>
> David Michonneau wrote:
>
>> Can you access that object from the report context object? If so, you can
>> retrieve that context in any chart script, by using
>> context.getScriptable().
>
>> Thanks,
>
>> David
>
>> "Justin" <justin@tradingmetrics.com> wrote in message
>> news:c8800a87fb77125e02baeb3861f63604$1@www.eclipse.org...
>>> It is running in a BIRT report, and it is an instance of a custom class.
>>>
>>> I want to do something similar to when you fill in columns for a
>>> scripted data set, except use the java object to fill in legend
>>> information.
>>>
>>>
>>> David Michonneau wrote:
>>>
>>>> First you need to import it with
>>>> importPackages(Packages.yourclass.full.name). This is the Rhino syntax.
>>>> Then I need more details to answer:
>>>
>>>> Is your chart running in standalone or inside a BIRT report?
>>>> Is the java object you refer to a standard Java object such as string
>>>> or you own custom class?
>>>
>>>> Thanks,
>>>
>>>> David
>>>
>>>> "Justin" <justin@tradingmetrics.com> wrote in message
>>>> news:7d200668edea2b8349c5e054568c5635$1@www.eclipse.org...
>>>>> How can you make a java object visible to a chart script?
>>>>> addScriptableJavaObject doesn't seem to do the trick.
>>>>>
>>>
>>>
>
>
|
|
|
Re: Java Object in Chart Scripts [message #244700 is a reply to message #244664] |
Mon, 25 June 2007 16:16  |
Eclipse User |
|
|
|
Originally posted by: emdeefive.gmail.com
Much Thanks!!
I'd still been using addscriptablejavaobject because it had been easier
not to change it from older versions.
I didn't recognize that the IReportContext returned by getScriptable was
the same one being used in the Report Engine code.
So many contexts....
Thanks,
Justin
David Michonneau wrote:
> addScriptableObject is deprecated, but you can register it in the appContext
> of IReportContext. To access it in a chart script, if you use
> IChartScriptContext.getExternalContext().getScriptable(), it will return you
> an instance of IReportContext
> So something like this should work:
> function beforeGeneration(chart, icsc) //any chart script function here
> {
>
icsc.getExternalContext().getScriptable().getAppContext().ge t( "variableName");
> }
> Thanks,
> David
> context.getScriptable().get
> "Justin" <justin@tradingmetrics.com> wrote in message
> news:e2b72acee7f5ad0d819598ef581dd3da$1@www.eclipse.org...
>>I found that method but couldn't figure out how to use it from the
>>documentation (or even the type it's supposed to return or from where.)
>>
>> Could you tell me how to do that? If I called addScriptableJavaObject(
>> myObject ) does that mean that it is already in the context?
>>
>> If not, how do I put it there?
>>
>> If so, how do I access it?
>>
>> Justin
>>
>>
>> David Michonneau wrote:
>>
>>> Can you access that object from the report context object? If so, you can
>>> retrieve that context in any chart script, by using
>>> context.getScriptable().
>>
>>> Thanks,
>>
>>> David
>>
>>> "Justin" <justin@tradingmetrics.com> wrote in message
>>> news:c8800a87fb77125e02baeb3861f63604$1@www.eclipse.org...
>>>> It is running in a BIRT report, and it is an instance of a custom class.
>>>>
>>>> I want to do something similar to when you fill in columns for a
>>>> scripted data set, except use the java object to fill in legend
>>>> information.
>>>>
>>>>
>>>> David Michonneau wrote:
>>>>
>>>>> First you need to import it with
>>>>> importPackages(Packages.yourclass.full.name). This is the Rhino syntax.
>>>>> Then I need more details to answer:
>>>>
>>>>> Is your chart running in standalone or inside a BIRT report?
>>>>> Is the java object you refer to a standard Java object such as string
>>>>> or you own custom class?
>>>>
>>>>> Thanks,
>>>>
>>>>> David
>>>>
>>>>> "Justin" <justin@tradingmetrics.com> wrote in message
>>>>> news:7d200668edea2b8349c5e054568c5635$1@www.eclipse.org...
>>>>>> How can you make a java object visible to a chart script?
>>>>>> addScriptableJavaObject doesn't seem to do the trick.
>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03502 seconds