Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » PersistentGlobalVariable in javascript switch block(usage of PersistentGlobalVariable in javascript switch block is always dropping into the default case.)
PersistentGlobalVariable in javascript switch block [message #1383992] Tue, 27 May 2014 17:35 Go to next message
Justin Paul is currently offline Justin PaulFriend
Messages: 2
Registered: May 2014
Junior Member
Hi,

Please bare with me on this one as I am totally new to BIRT and java/javascript.

I setup a PersistentGlobalVariable based on a report parameter (string). I then pass this global variable to a function which executes a Javascript switch block. The problem is that it appears to be always dropping into the default case.

Notes:

When I replace the "switch" with "IF Else" then it works as excepted and it hits the right if condition....

Also, when I pass the parameter directly then it the "switch" works fine and it hit the expected case...

Can anyone explain what could be happening???? Please and thanks.

Here are the code details

Input parameter = "BOB,JACK"

1) setup the global variable

function reportCommon() {

var nameList = params["parmNameList"].value;
reportContext.setPersistentGlobalVariable("gvarNameList", nameList);

} //end function 1

2) build a final statement by calling another function to process "switch"

function buildStatement() {

var nmList = reportContext.getPersistentGlobalVariable("gvarNameList");

// Note if the above is commented out and the below is used everything works fine
// nmList = params["parmNameList"].value;

if (nmList)
{
var nm = nmList.split(",");
var arrayLength = nm.length;
for (var i = 0; i < arrayLength; i++) {
var myStatement = getStatement(nm[i]); }
}

} // end function 2

3) function to use "switch" , Note: the IF block works as expected

function getStatement(inStr) {

if (inStr = "BOB") { Packages.java.lang.System.out.println("Hi There: " + inStr);

switch(instr)
{
case "BOB": { // not getting in here
Packages.java.lang.System.out.println("Case Hi There Jack");
break;
}
case "JACK": { // not getting in here
Packages.java.lang.System.out.println("Case Hi There Jack");
break;
}
default:{ // always dropping in here
Packages.java.lang.System.out.println("Inside of default");
}
} // end switch
} //end function 3

Please help! Thanks
Re: PersistentGlobalVariable in javascript switch block [message #1384005 is a reply to message #1383992] Tue, 27 May 2014 19:43 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Could you attach a simple design that recreates your issue that I can run so I know exactly where you're putting everything and can test on it? Thanks.

Michael

Developer Evangelist, Silanis
Re: PersistentGlobalVariable in javascript switch block [message #1384022 is a reply to message #1384005] Tue, 27 May 2014 21:56 Go to previous messageGo to next message
Justin Paul is currently offline Justin PaulFriend
Messages: 2
Registered: May 2014
Junior Member
Hi Michael,

Please see attached, hopefully you can make sense of it. Note, I could not get the javascript to work as a separate file that I include as a resource. Guess that is another topic, but I was able to achieve recreating the same issue by putting all the script into the Report Initialize.

Thanks for looking into this!
Re: PersistentGlobalVariable in javascript switch block [message #1804473 is a reply to message #1384022] Tue, 26 March 2019 13:55 Go to previous message
x louk is currently offline x loukFriend
Messages: 5
Registered: March 2019
Junior Member
Hello Justin,

have you found a solution? In Birt 4.8.0 this issue still persists.
Previous Topic:Interactive functions for charts in BIRT 2.0.1
Next Topic:User Defined Sort On Grouped Data
Goto Forum:
  


Current Time: Tue Oct 22 19:03:49 GMT 2019

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

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

Back to the top