cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robby Pelssers" <robby.pelss...@ciber.com>
Subject RE: Can't use switch with cocoon.request.get in flowscript [SOLUTION]
Date Tue, 09 Feb 2010 10:29:55 GMT
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:t.markus@proventis.net] 
Sent: Tuesday, February 09, 2010 11:16 AM
To: users@cocoon.apache.org
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org

Mime
View raw message