Hmm,

Yes ... I actually tried to create a new String which probably still did create 
a java.lang.String 

var cmd = new String(cocoon.request.getParameter("cmd"));   // -> If I'm right 
I tried this solution but it did not work



I just tried the proposed typeconversion 

        var cmd = String(cocoon.request.getParameter("cmd"));

which did work like a charm so this solution is a cleaner one.

Cheers,
Robby


-----Original Message-----
From: Thomas Markus [mailto:[email protected]] 
Sent: Tuesday, February 09, 2010 11:16 AM
To: [email protected]
Subject: Re: Can't use switch with cocoon.request.get in flowscript [SOLUTION]

hi,

use an type conversion (to javascript string) instead of string concat:

switch (String(cmd)) {
    ...
}

regards
Thomas

> <snip>
>
> function testSwitch() {
>       var cmd = getCmd("cmd");
>       switch(cmd) {
>           case "save": 
>                   print("request parameter was save");
>                   break;
>           case "delete": 
>                   print("request parameter was delete");
>                   break;
>               default:
>                   print("request parameter was none of the above");
>                   break;                      
>       }
> }
>
>
> function getCmd(name) {
>       return "" + cocoon.request.getParameter(name);  // --> we need to make 
> sure we get a native javascript object so our switch will work
> }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to