Scripted Dataset handler open event.

Options
stuart
edited February 11, 2022 in Analytics #1
Can anyone tell me why the open() event handler of a java scripted dataset would be called multiple times.

Thanks.

Comments

  • stuart
    edited December 31, 1969 #2
    Options
    Ok, I now understand that a scripted data set event handler will be called multiple times if the scripted data set is bound to more than one report item.

    What if a scripted data set is bound to a report item and also used in a join with another data set (the join is then bound to a chart) will this mean that the scripted data set events will be called twice?

    Further is it possible to define a scripted data source, override the open() event handler for the scripted data source to retrieve the required data for the report and reference this scripted data source in the reports scripted data sets so that the scripted data is retrieved only once?

    Thanks.
  • stuart
    edited December 31, 1969 #3
    Options
    Is it possible to define a scripted data source, override the beforeOpen() event handler for the scripted data source to retrieve the required data for the report and reference this scripted data source in the reports scripted data sets so that the scripted data is retrieved only once?

    It seems that this should be possible from the "Integrating and Extending BIRT" book on pg 118 it says:

    "About data source and data set events
    Events for data source and data set elements trigger just prior to creating the
    report item bound to the data set. This sequence occurs for every report item
    bound to a data set with the exception of the data source beforeOpen and
    afterOpen events. These events do not trigger if a data source has already been used."

    However, the beforeOpen event handler in my case is being called multiple times. Any ideas as to why this would be the case?

    Thanks.
  • stuart
    edited December 31, 1969 #4
    Options
    Does anyone know the answer?
  • bhanley
    edited December 31, 1969 #5
    Options
    The purpose of the open event is to populate your data model (array of java objects generally) with data. If you want to do this once and only once, move this action to a script that fires off once.

    The issue is accessing the array of Java Objects (each of which being a "row" on your data set). The use of a Persistent global variable inside a BIRT Report will make your variable (array) available across different controls on the report. In order to set a persistent global variable your target value needs to be serializable. If this is a huge hit in terms of resources, that may be worth implementing.

    I can try and work up a test case for this today or early tomorrow. I have not tried this out personally, but in theory it should work fine.
    Warning No formatter is installed for the format ipb
  • stuart
    edited December 31, 1969 #6
    Options
    Thanks for your reply Brian ....

    "The purpose of the open event is to populate your data model (array of java objects generally) with data. If you want to do this once and only once, move this action to a script that fires off once. "

    That is exactly what I'm trying to do ... but the beforeOpen event of the scriptedDataSource, in my case, fires more than once. Should this be the case or am I doing something wrong? If I can't put the script (ie my Java Event Handler - not javascript) in the beforeOpen method then where can I put it? I need access to the reportcontext to retrieve report parameters and also I would prefer it if I can "unpack" any array of data in a scripted data set as I need to do joins between two datasets.

    "The issue is accessing the array of Java Objects (each of which being a "row" on your data set). The use of a Persistent global variable inside a BIRT Report will make your variable (array) available across different controls on the report. In order to set a persistent global variable your target value needs to be serializable. If this is a huge hit in terms of resources, that may be worth implementing. "

    My biggest performance hit at the moment is a hibernate query to retrieve the data.

    So BIRT doesn't do data caching? Should I be able to use joint datasets so that I don't get into a "data" binding issue? ie repeated calls to the scripted dataset?

    "I can try and work up a test case for this today or early tomorrow. I have not tried this out personally, but in theory it should work fine. "

    Any help will be much appreciated. Thanks.
  • actuser9
    edited August 3, 2012 #7
    Options
    Hi,<br />
    <br />
    I am having the same issue with the scripted data set being called multiple times due to the fact that the scripted dataset is being binded to different elements in the report.<br />
    <br />
    Did anyone find a solution to this? <a class='bbc_url' href='http://www.birt-exchange.org/org/forum/public/style_emoticons/'>http://www.birt-exchange.org/org/forum/public/style_emoticons/</a><#EMO_DIR#>/confused.gif <br />
    <br />
    Thanks<br />
    UY
    Warning No formatter is installed for the format ipb
  • actuser9
    edited December 31, 1969 #8
    Options
    I could find and implement the solution from this post. Hope this helps someone with the similar issue.

    Using the 'before factory' event to call the java method did the trick.

    http://www.eclipse.org/forums/index.php/m/843198/#msg_843198

    Thanks
    UY
    Warning No formatter is installed for the format ipb
  • <p>Can anyone find a solution for this problem. I am using 2 datasource in beforeopen method and only one function is working and another not working.</p>
    <p> </p>
    <p>Thanks in advance</p>
  • <p>Is really community is active ???</p>