Home » Archived » BIRT » ScriptDataSet: Import packages
ScriptDataSet: Import packages [message #245675] |
Sat, 30 June 2007 07:33  |
Eclipse User |
|
|
|
Originally posted by: blaxter.gmail.com
Hello,
I'm having some issues and i can't figure out why birt doesn't like my java
objects :(.
Now, i'm using (the context is that i've opened a rptdesign and i'm going to create a rptdocument):
task.addScriptableJavaObject("data", FactoryData.getData()); //it's Iterator<Iterator>
with that, i can, in a script data set, obtain the data with the following code:
open:
iter = data;
fetch:
if(!iter.hasNext()){
return false;
}
var node = iter.next( );
row.ROW1 = node.next( );
row.ROW2 = node.next( );
return true;
it works, but it seems that addScriptableJavaObject is deprecated,
so i'm trying to use the method explain in the wiki [1].
In the same project i've created the class FactoryData in birtSamples package.
So in the script DataSet i've modified the open method just like this:
open method now looks like:
importPackage( Packages.birtSamples );
iter = FactoryData.getData();
but exception will throw :(
WARNING: A BIRT exception occurred: Error evaluating Javascript expression. Script engine error: ReferenceError: "FactoryData" is not defined. (DataSet[Data Set].__bm_OPEN#3)
Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
(...)
it's a tipical classpath problem, [1] says that:
// the jar containing the class should be in :
// eclipse\plugins\org.eclipse.birt.report.viewer\birt\WEB-INF\ lib or
// eclipse\plugins\org.eclipse.birt.report.viewer\birt\scriptli b
//
but i'm not using the viewer or anything like that, i'm just want to create a
rptdocument, if my class it's in the classpath, i do not understand why birt can't found it :-/.
Any help would be greatly appreciated, Jesús.
[1] http://wiki.eclipse.org/BIRT/FAQ/Data_Access#Q:_How_do_I_get _data_from_a_POJO_.28Plain_Old_Java_Object.29.3F
|
|
|
Re: ScriptDataSet: Import packages [message #245702 is a reply to message #245675] |
Sat, 30 June 2007 15:11   |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Jesús,
task.addScriptableJavaObject is deprecated, but has been replaced with:
HashMap hm = config.getAppContext();
hm.put( "data", FactoryData.getData());
config.setAppContext(hm);
As far as the code not finding your class:
Is FactoryData.getData() a static method?
If not you have not created an instance of FactoryData in your script.
Jason
Jesús GS wrote:
> Hello,
> I'm having some issues and i can't figure out why birt doesn't like my java
> objects :(.
>
> Now, i'm using (the context is that i've opened a rptdesign and i'm going to create a rptdocument):
> task.addScriptableJavaObject("data", FactoryData.getData()); //it's Iterator<Iterator>
>
> with that, i can, in a script data set, obtain the data with the following code:
> open:
> iter = data;
>
> fetch:
> if(!iter.hasNext()){
> return false;
> }
> var node = iter.next( );
> row.ROW1 = node.next( );
> row.ROW2 = node.next( );
> return true;
>
> it works, but it seems that addScriptableJavaObject is deprecated,
> so i'm trying to use the method explain in the wiki [1].
>
> In the same project i've created the class FactoryData in birtSamples package.
> So in the script DataSet i've modified the open method just like this:
>
> open method now looks like:
>
> importPackage( Packages.birtSamples );
> iter = FactoryData.getData();
>
> but exception will throw :(
>
> WARNING: A BIRT exception occurred: Error evaluating Javascript expression. Script engine error: ReferenceError: "FactoryData" is not defined. (DataSet[Data Set].__bm_OPEN#3)
> Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
> (...)
>
> it's a tipical classpath problem, [1] says that:
> // the jar containing the class should be in :
> // eclipse\plugins\org.eclipse.birt.report.viewer\birt\WEB-INF\ lib or
> // eclipse\plugins\org.eclipse.birt.report.viewer\birt\scriptli b
> //
> but i'm not using the viewer or anything like that, i'm just want to create a
> rptdocument, if my class it's in the classpath, i do not understand why birt can't found it :-/.
>
> Any help would be greatly appreciated, Jesús.
>
> [1] http://wiki.eclipse.org/BIRT/FAQ/Data_Access#Q:_How_do_I_get _data_from_a_POJO_.28Plain_Old_Java_Object.29.3F
|
|
|
Re: ScriptDataSet: Import packages [message #245736 is a reply to message #245702] |
Sun, 01 July 2007 11:12   |
Eclipse User |
|
|
|
Originally posted by: blaxter.gmail.com
With this method, the "data" object will be accesible by all task created
with this config, isn't it? it could happen serious problems of
concurrency.
if i've several proccess using the same IReportEngine, and i'm creating
IRunTask with
reportEngine.createRunTask(reportEngine.openReportDeisgn(__s ome_design__))
i guess that if i do a task.addScriptableJavaObject("data", __some_object)
that 'data' will be visible only for this specific task, and the others
tasks (which are running concurrently) could have another object with the
same name.
> Jesús,
>
> task.addScriptableJavaObject is deprecated, but has been replaced with:
>
> HashMap hm = config.getAppContext();
> hm.put( "data", FactoryData.getData());
> config.setAppContext(hm);
>
> As far as the code not finding your class:
>
> Is FactoryData.getData() a static method?
> If not you have not created an instance of FactoryData in your script.
>
> Jason
>
>
> Jesús GS wrote:
>> Hello,
>> I'm having some issues and i can't figure out why birt doesn't like my java
>> objects :(.
>>
>> Now, i'm using (the context is that i've opened a rptdesign and i'm going to create a rptdocument):
>> task.addScriptableJavaObject("data", FactoryData.getData()); //it's Iterator<Iterator>
>>
>> with that, i can, in a script data set, obtain the data with the following code:
>> open:
>> iter = data;
>>
>> fetch:
>> if(!iter.hasNext()){
>> return false;
>> }
>> var node = iter.next( );
>> row.ROW1 = node.next( );
>> row.ROW2 = node.next( );
>> return true;
>>
>> it works, but it seems that addScriptableJavaObject is deprecated,
>> so i'm trying to use the method explain in the wiki [1].
>>
>> In the same project i've created the class FactoryData in birtSamples package.
>> So in the script DataSet i've modified the open method just like this:
>>
>> open method now looks like:
>>
>> importPackage( Packages.birtSamples );
>> iter = FactoryData.getData();
>>
>> but exception will throw :(
>>
>> WARNING: A BIRT exception occurred: Error evaluating Javascript expression. Script engine error: ReferenceError: "FactoryData" is not defined. (DataSet[Data Set].__bm_OPEN#3)
>> Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
>> (...)
>>
>> it's a tipical classpath problem, [1] says that:
>> // the jar containing the class should be in :
>> // eclipse\plugins\org.eclipse.birt.report.viewer\birt\WEB-INF\ lib or
>> // eclipse\plugins\org.eclipse.birt.report.viewer\birt\scriptli b
>> //
>> but i'm not using the viewer or anything like that, i'm just want to create a
>> rptdocument, if my class it's in the classpath, i do not understand why birt can't found it :-/.
>>
>> Any help would be greatly appreciated, Jesús.
>>
>> [1] http://wiki.eclipse.org/BIRT/FAQ/Data_Access#Q:_How_do_I_get _data_from_a_POJO_.28Plain_Old_Java_Object.29.3F
|
|
|
Re: ScriptDataSet: Import packages [message #245908 is a reply to message #245736] |
Mon, 02 July 2007 10:12  |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
You can call getAppContext() on the task as well.
Jason
Jesús GS wrote:
> With this method, the "data" object will be accesible by all task created
> with this config, isn't it? it could happen serious problems of
> concurrency.
>
> if i've several proccess using the same IReportEngine, and i'm creating
> IRunTask with
> reportEngine.createRunTask(reportEngine.openReportDeisgn(__s ome_design__))
>
> i guess that if i do a task.addScriptableJavaObject("data", __some_object)
> that 'data' will be visible only for this specific task, and the others
> tasks (which are running concurrently) could have another object with the
> same name.
>
>
>> Jesús,
>>
>> task.addScriptableJavaObject is deprecated, but has been replaced with:
>>
>> HashMap hm = config.getAppContext();
>> hm.put( "data", FactoryData.getData());
>> config.setAppContext(hm);
>>
>> As far as the code not finding your class:
>>
>> Is FactoryData.getData() a static method?
>> If not you have not created an instance of FactoryData in your script.
>>
>> Jason
>>
>>
>> Jesús GS wrote:
>>> Hello,
>>> I'm having some issues and i can't figure out why birt doesn't like my java
>>> objects :(.
>>>
>>> Now, i'm using (the context is that i've opened a rptdesign and i'm going to create a rptdocument):
>>> task.addScriptableJavaObject("data", FactoryData.getData()); //it's Iterator<Iterator>
>>>
>>> with that, i can, in a script data set, obtain the data with the following code:
>>> open:
>>> iter = data;
>>>
>>> fetch:
>>> if(!iter.hasNext()){
>>> return false;
>>> }
>>> var node = iter.next( );
>>> row.ROW1 = node.next( );
>>> row.ROW2 = node.next( );
>>> return true;
>>>
>>> it works, but it seems that addScriptableJavaObject is deprecated,
>>> so i'm trying to use the method explain in the wiki [1].
>>>
>>> In the same project i've created the class FactoryData in birtSamples package.
>>> So in the script DataSet i've modified the open method just like this:
>>>
>>> open method now looks like:
>>>
>>> importPackage( Packages.birtSamples );
>>> iter = FactoryData.getData();
>>>
>>> but exception will throw :(
>>>
>>> WARNING: A BIRT exception occurred: Error evaluating Javascript expression. Script engine error: ReferenceError: "FactoryData" is not defined. (DataSet[Data Set].__bm_OPEN#3)
>>> Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
>>> (...)
>>>
>>> it's a tipical classpath problem, [1] says that:
>>> // the jar containing the class should be in :
>>> // eclipse\plugins\org.eclipse.birt.report.viewer\birt\WEB-INF\ lib or
>>> // eclipse\plugins\org.eclipse.birt.report.viewer\birt\scriptli b
>>> //
>>> but i'm not using the viewer or anything like that, i'm just want to create a
>>> rptdocument, if my class it's in the classpath, i do not understand why birt can't found it :-/.
>>>
>>> Any help would be greatly appreciated, Jesús.
>>>
>>> [1] http://wiki.eclipse.org/BIRT/FAQ/Data_Access#Q:_How_do_I_get _data_from_a_POJO_.28Plain_Old_Java_Object.29.3F
|
|
|
Goto Forum:
Current Time: Sun May 11 07:18:18 EDT 2025
Powered by FUDForum. Page generated in 0.02370 seconds
|