Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323366 - set and get PersistentGlobalVariable of dataset row
Summary: set and get PersistentGlobalVariable of dataset row
Status: RESOLVED WONTFIX
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.6.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Birt-ReportEngine-inbox@eclipse.org CLA
QA Contact: Xiaoying Gu CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-23 04:32 EDT by Arco CLA
Modified: 2010-08-25 13:20 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arco CLA 2010-08-23 04:32:11 EDT
Build Identifier: 20100617-1415

I'm running into some troubles using set and get PersistentGlobalVariable.

I'm setting the variable in the onFetch event of the dataset and try to get it in the onRender of a text element.

When I set the variable with "reportContext.setPersistentGlobalVariable('state',row['STATE']);"
and get it with 
"var state = reportContext.getPersistentGlobalVariable('state');
this.text = state;"
this works fine.
But actually I want to save the whole record instead of just the state so I changed the code to.
"reportContext.setPersistentGlobalVariable('customer',row);"
"var customer = reportContext.getPersistentGlobalVariable('customer');
this.text = customer['STATE'];"

For some reason this doesn't work, the text field is empty.


Reproducible: Always
Comment 1 Wei Yan CLA 2010-08-24 13:59:22 EDT
As BIRT needs save the value to disk, so the value should be a Serializable object. The row object is not inherited from Serializable. 

Another issue is BIRT only saves one instance of global variable. It means if you set the global variable twice, only the last value is saved into the document.
Comment 2 Arco CLA 2010-08-25 03:23:13 EDT
Ok clear for me, does this mean this will be solved in a future release or not?
Your point that only one instance is saved is ok with me, there's only one record in the dataset.
The thing is I want to save that record as a global variable so I can use it everywhere in the report for hiding elements based on the values in this record without binding the dataset on those elements.
Comment 3 Wei Yan CLA 2010-08-25 13:20:19 EDT
No, the value must be a serializable otherwise we can't save it into the document. You can save the row value to a hashmap before setting it to the global variable.

I close this entry as won't fixed.

thanks.