Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Set a global variable using report parameter(Which event must be handled in order to have the parameter already set?)
Set a global variable using report parameter [message #820661] Wed, 14 March 2012 12:03 Go to next message
ing omini is currently offline ing ominiFriend
Messages: 26
Registered: March 2012
Junior Member
I want to read a report parameter and, basing on its value, create some derived variables to be put in the report context:

reportContext.setGlobalVariable("global_refdate", params["refdate"].value);


The final goal is to use these variables inside dynamic text elements, report header/footer, ...

The problem is that I can't understand where to put the script, because I don't know when the parameter is evaluated (and not null) during the report generation.

I've put it in many event handler scripts of the report element:

initialize
before factory
after factory

but the global variable is always null when I'm trying to use it with:

reportContext.getPersistentGlobalVariable("global_refdate");



Can someone help me, please?
Thanks in advance...
Re: Set a global variable using report parameter [message #820768 is a reply to message #820661] Wed, 14 March 2012 14:47 Go to previous messageGo to next message
ing omini is currently offline ing ominiFriend
Messages: 26
Registered: March 2012
Junior Member
A friend suggested me the solution: I was not setting the variable as "Persistent".


WRONG --> reportContext.setGlobalVariable("global_refdate", params["refdate"].value);
CORRECT --> reportContext.setPersistentGlobalVariable("global_refdate", params["refdate"].value);


Now it seems working, by putting the script in the initialize event handler of report component.

Thanks anyway...
Re: Set a global variable using report parameter [message #821037 is a reply to message #820661] Wed, 14 March 2012 21:35 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

The beforeFactory is ideal. Are you setting global variable like:
setPersistentGlobalVariable or using setGlobalVariable?
the get must match.

Jason

On 3/14/2012 8:03 AM, ing omini wrote:
> I want to read a report parameter and, basing on its value, create some
> derived variables to be put in the report context:
>
> reportContext.setGlobalVariable("global_refdate", params["refdate"].value);
>
> The final goal is to use these variables inside dynamic text elements,
> report header/footer, ...
>
> The problem is that I can't understand where to put the script, because
> I don't know when the parameter is evaluated (and not null) during the
> report generation.
>
> I've put it in many event handler scripts of the report element:
>
> initialize
> before factory
> after factory
>
> but the global variable is always null when I'm trying to use it with:
>
> reportContext.getPersistentGlobalVariable("global_refdate");
>
>
> Can someone help me, please?
> Thanks in advance...
>
Re: Set a global variable using report parameter [message #831941 is a reply to message #821037] Thu, 29 March 2012 14:51 Go to previous message
ing omini is currently offline ing ominiFriend
Messages: 26
Registered: March 2012
Junior Member
I will try with "beforeFactory"...
Thanks
Previous Topic:Data set expressions and design element expressions
Next Topic:Problems with hyperlinks on images/report designer
Goto Forum:
  


Current Time: Thu Apr 25 21:13:12 GMT 2024

Powered by FUDForum. Page generated in 0.03042 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top