Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Report variables cannot be changed(Report variable default values cannot be altered in either java or javascript)
Report variables cannot be changed [message #721507] Thu, 01 September 2011 23:30 Go to next message
Richard  is currently offline Richard Friend
Messages: 7
Registered: September 2011
Junior Member
We are trying to derive some control values from report parameters. We thought we could use the global variables in the report context, but these don't appear to be the same as the report variables you declare in the Report Design view. We were having trouble in a fairly complicated report in which we use Java event handlers. As a simple test, we created a simple report (no data and no parameters). The report is attached.

In Eclipse Report Design , we created two report variables: testAlphaVariable and testIntegerVariable. We checked "report variable", not "page variable."

The default for the first was set to "a" and for the second to 1.

On the report layout we show only the two variables with labels.

We simply dragged the variables into the report. The javascript expression for the first variable is: vars["testAlphaVariable"]

A preview showed the two variables with the default values specified.

Then we tried to override the default value of the first variable by setting it with javascript in Initialize:

reportContext.setGlobalVariable("testAlphaVariable", "B");

This, however, had no affect. Preview still showed the default value.

It appears that the report context global variable is not the same as the variable defined to the report. So in what sense are the variables defined to the report variable? How do you change them?

Perhaps we have taken the wrong approach. We want to control what appears in some cell in the report by a using global variable and then testing its value. But that does not work by using vars["variable name"], which always seems to get the default. This is the important question: How do we change the value that appears on the report based on values derived from those that come in as parameters? How do we set up intermediate variables to control what appears?
Re: Report variables cannot be changed [message #721707 is a reply to message #721507] Fri, 02 September 2011 15:59 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

This is probably bad naming issue. SetGlobalVariable does not set
report variables but a script global variable. You can get it in an
expression like reportContext.getGlobalVariable. To set a Report
variable ( which were initially intended for pagination variable eg page
n of m for the master page of a report - although they have changed in
scope) use reportContext.setPageVariable . This method works for both
types of report variables.

Jason

On 9/1/2011 7:30 PM, Richard wrote:
> We are trying to derive some control values from report parameters. We thought we could use the global variables in the report context, but these don't appear to be the same as the report variables you declare in the Report Design view. We were having trouble in a fairly complicated report in which we use Java event handlers. As a simple test, we created a simple report (no data and no parameters). The report is attached.
>
> In Eclipse Report Design , we created two report variables: testAlphaVariable and testIntegerVariable. We checked "report variable", not "page variable."
>
> The default for the first was set to "a" and for the second to 1.
>
> On the report layout we show only the two variables with labels.
>
> We simply dragged the variables into the report. The javascript expression for the first variable is: vars["testAlphaVariable"]
>
> A preview showed the two variables with the default values specified.
>
> Then we tried to override the default value of the first variable by setting it with javascript in Initialize:
>
> reportContext.setGlobalVariable("testAlphaVariable", "B");
>
> This, however, had no affect. Preview still showed the default value.
>
> It appears that the report context global variable is not the same as the variable defined to the report. So in what sense are the variables defined to the report variable? How do you change them?
>
> Perhaps we have taken the wrong approach. We want to control what appears in some cell in the report by a using global variable and then testing its value. But that does not work by using vars["variable name"], which always seems to get the default. This is the important question: How do we change the value that appears on the report based on values derived from those that come in as parameters? How do we set up intermediate variables to control what appears?
>
Re: Report variables cannot be changed [message #723223 is a reply to message #721707] Thu, 08 September 2011 05:27 Go to previous message
Richard  is currently offline Richard Friend
Messages: 7
Registered: September 2011
Junior Member
Thank God. Your reply cleared up the mystery and is the key to doing much within BIRT.

Yes, the the naming is a problem. As BIRT distinguishes between "Report Variables" and "Page Variables," it is reasonable to guess that setGlobalVariable applies to the first and setPageVariable to the second. Only when you look in the xml source do you see that both "Report" and "Page" variables are implemented as "page variables". You indicate that the page variables and the global variables evolved for different purposes (the former to communicate among scripts at different entry points and latter for pagination elements). However, given that both the Report variable and the Global variable are intended to have report-wide scope, why should they continue to have different implementations?

You may be able to help with another problem. Will start a new topic.
Previous Topic:BIRT report into the browser
Next Topic:Adding tooltip to image
Goto Forum:
  


Current Time: Fri Apr 26 09:11:16 GMT 2024

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

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

Back to the top