Q:

Using Javascript reportContext.setPersistentGlobalVariable method on Birt handlers To pass objects between processes

I trying to pass variable from the factory process to the run process , 
using reportContext.setPersistentGlobalVariable in the eclipsde UI perspective.
In the onFetch() of the data set the code look like this:
var flag = "hello";
reportContext.setPersistentGlobalVariable("flag", flag);

In the beforeRender() method of the report design the code look like this:
var flg = reportContext.getPersistentGlobalVariable("flag");
reportContext.getDesignHandle().findElement("text").setContent(flg);

It should be noted that this code is works when I put the two snippets in two of the report design on..() methods.
Somehow the data not pass between the two processes.

A:

I was able to reproduce a behavior similar to what you describe. Please try to insert a Dynamic text element at the end of the report and set this expression, it should work:
reportContext.getPersistentGlobalVariable("flag");

Most likely your reports are running with a unique "RunAndRender" task, whereas if we want to take advantage of beforeRender & onRender events we should use two separate "Run" and "Render" task. 
In practice with Eclipse Designer, if we run reports using the Web Viewer ("View report in Web Viewer") there are two separate tasks but if we directly run an export ("View report as xxx") there is a single task. 
That said, it is important to notice handling render events is tricky: most of the time it is too late to change designHandle elements as you try to do here. Even the "visibility" property of elements can't be changed at render time, for example. You can change the content of a text using "onRender" event of this element though:
this.text=reportContext.getPersistentGlobalVariable("flag");

