Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Java Object in Chart Scripts
Java Object in Chart Scripts [message #244312] Fri, 22 June 2007 15:29 Go to next message
Eclipse UserFriend
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 #244341 is a reply to message #244312] Fri, 22 June 2007 15:54 Go to previous messageGo to next message
David Michonneau is currently offline David MichonneauFriend
Messages: 1145
Registered: July 2009
Senior Member
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 #244350 is a reply to message #244341] Fri, 22 June 2007 15:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: justin.tradingmetrics.com

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 #244390 is a reply to message #244350] Fri, 22 June 2007 18:19 Go to previous messageGo to next message
David Michonneau is currently offline David MichonneauFriend
Messages: 1145
Registered: July 2009
Senior Member
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 #244395 is a reply to message #244390] Fri, 22 June 2007 18:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: justin.tradingmetrics.com

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.
>>>>
>>
>>
Please Help!! [message #244574 is a reply to message #244395] Mon, 25 June 2007 13:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: emdeefive.gmail.com

Could someone please help me out here?
Specifically,

1. How can I make a Java object accessible from a chart script (I think
more specifically from the IChartScriptContext object that is already
visible) and,

2. How can I access the Java object from the context object.

In a scripted data set, the method you use would be
addScriptableJavaObject, is there a similar method to make such an object
part of the script context?

Please Help!

Justin
Re: Java Object in Chart Scripts [message #244664 is a reply to message #244395] Mon, 25 June 2007 19:13 Go to previous messageGo to next message
David Michonneau is currently offline David MichonneauFriend
Messages: 1145
Registered: July 2009
Senior Member
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 20:16 Go to previous message
Eclipse UserFriend
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.
>>>>>>
>>>>
>>>>
>>
>>
Previous Topic:Text editor locked
Next Topic:JS and Date / String Conversion
Goto Forum:
  


Current Time: Fri Sep 27 13:29:31 GMT 2024

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

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

Back to the top