Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323366

Summary: set and get PersistentGlobalVariable of dataset row
Product: z_Archived Reporter: Arco <coolplexpert>
Component: BIRTAssignee: Birt-ReportEngine-inbox <Birt-ReportEngine-inbox>
Status: RESOLVED WONTFIX QA Contact: Xiaoying Gu <bluesoldier>
Severity: normal    
Priority: P3 CC: bluesoldier, coolplexpert, wyan
Version: 2.6.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

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.