You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Schmitz, Jeffrey A" <Je...@boeing.com> on 2010/02/08 16:55:04 UTC

Can't use switch with cocoon.request.get in flowscript

Hello,
   In Cocoonn 2.1, does anyone know why I can't use a switch command with the result of cocoon.request.get in flowscript?  if's work just fine, but switch doesn't.  E.g. to get the switch to work I have to do the following:

     var cmd = cocoon.request.get("Cmd");

     //For some reason, the switch doesn't work with the
     //string returned from cocoon.request.get, but if
     //statements do.
     if (cmd == "Open") {
        cmd = "Open";
     }
     if (cmd == "Create Model") {
        cmd = "Create Model";
     }
     if (cmd == "Account") {
         cmd = "Account";
      }
     if (cmd == "Logout") {
        cmd = "Logout";
     }

     switch (cmd) {

        case "Open":
                  ...

I have tried adding .toString() to the end of the get function and also the cmd variable in various places, but that doesn't work either.

Thanks!
Jeff




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Can't use switch with cocoon.request.get in flowscript [SOLUTION]

Posted by Robby Pelssers <ro...@ciber.com>.
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


Re: Can't use switch with cocoon.request.get in flowscript [SOLUTION]

Posted by Thomas Markus <t....@proventis.net>.
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


RE: Can't use switch with cocoon.request.get in flowscript [SOLUTION]

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
Thanks!  Really cleans up my code.  I'm just surprised this issue hasn't been raised before here.

Jeff

 

> -----Original Message-----
> From: Robby Pelssers [mailto:robby.pelssers@ciber.com] 
> Sent: Tuesday, February 09, 2010 4:03 AM
> To: users@cocoon.apache.org
> Subject: RE: Can't use switch with cocoon.request.get in 
> flowscript [SOLUTION]
> 
> Hi Jeff,
> 
> I did a similar setup in  a Cocoon2.2 block and the same 
> problem occurs:
> 
> function testSwitch() {
> 	var cmd = cocoon.request.getParameter("cmd");
> 	
> 	print("cmd=" + cmd);
> 	print(cmd.getClass().getName());
> 	
> 	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;			
> 	}
> }
> 
> 
> Output in console:
> cmd=delete
> java.lang.String
> request parameter was none of the above
> 
> By the way... cmd.getClass().getName() is only possible if 
> the object is in fact a java object.  They use LiveConnect so 
> you can easily use Java and JavaScript together.  I suspect 
> that the switch does not work properly on java.lang.String.
> 
> So when you convert the cmd to a native javascript object it 
> suddenly will work again.  A better solution is demonstrated below:
> 
> 
> 
> 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 }
> 
> Kind regards,
> Robby
> 
> -----Original Message-----
> From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> Sent: Monday, February 08, 2010 6:59 PM
> To: users@cocoon.apache.org
> Subject: RE: Can't use switch with cocoon.request.get in flowscript
> 
> In effect, I already do that with the following code which is 
> my workaround.  In this case the switch DOES work.
> 
>      var cmd = cocoon.request.get("Cmd");
> 
>      //For some reason, the switch doesn't work with the
>      //string returned from cocoon.request.get, but if
>      //statements do.
>      if (cmd == "Open") {
>         cmd = "Open";
>      }
>      if (cmd == "Create Model") {
>         cmd = "Create Model";
>      }     
>      if (cmd == "Account") {
>          cmd = "Account";
>       } 
>      if (cmd == "Logout") {
>         cmd = "Logout";
>      } 
>      
>      switch (cmd) {
> 
>         case "Open":
> 
> Jeff
> Work: 314-232-1997
> Cell: 636-448-5990
>  
> 
> > -----Original Message-----
> > From: Robby Pelssers [mailto:robby.pelssers@ciber.com]
> > Sent: Monday, February 08, 2010 11:56 AM
> > To: users@cocoon.apache.org
> > Subject: RE: Can't use switch with cocoon.request.get in flowscript
> > 
> > A next step would be to try something like
> > 
> >      var cmd = "Open";
> >      print("cmd='" + cmd = "'");
> > 
> >      switch (cmd) {
> >         case "Open": 
> >             {
> >                 print("Command is Open");
> >                 break;
> >             }
> >         case "Create Model": 
> >             {
> >                 print("Command is Create Model");
> >                 break;   
> >             }
> >        case default:
> >             {
> >                 print("Command did not match any of the above");
> >                 break;   
> >             }
> >      }
> > 
> > If this snippet still does print the default output you 
> know for sure 
> > the switch is not behaving properly.
> > 
> > https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference
> > /Statements/switch
> > 
> > So can you first see what the output of the snippet above is?
> > 
> > Cheers,
> > Robby
> > 
> > 
> > 
> > -----Original Message-----
> > From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> > Sent: Monday, February 08, 2010 5:45 PM
> > To: users@cocoon.apache.org
> > Subject: RE: Can't use switch with cocoon.request.get in flowscript
> > 
> > Here's the output.  Very strange.  Again, 'if' check's work 
> on it, but 
> > the switch command doesn't unless I do the workaround.
> > 
> >  cmd='Open'
> >  Command did not match any of the above
> > 
> > Jeff
> > Work: 314-232-1997
> > Cell: 636-448-5990
> >  
> > 
> > > -----Original Message-----
> > > From: Robby Pelssers [mailto:robby.pelssers@ciber.com]
> > > Sent: Monday, February 08, 2010 10:27 AM
> > > To: users@cocoon.apache.org
> > > Subject: RE: Can't use switch with cocoon.request.get in 
> flowscript
> > > 
> > > Well,
> > > 
> > > I know for sure the switch works fine in cocoon2.2.  Might not be 
> > > implemented properly in an older version of Rhino?
> > > 
> > > Anyway...
> > > 
> > > What happens if you use this snippet??  It should at least print 
> > > something to your console.
> > > 
> > >      var cmd = cocoon.request.get("Cmd");
> > >      print("cmd='" + cmd = "'");
> > > 
> > >      switch (cmd) {
> > >         case "Open": 
> > >             {
> > >                 print("Command is Open");
> > >                 break;
> > >             }
> > >         case "Create Model": 
> > >             {
> > >                 print("Command is Create Model");
> > >                 break;   
> > >             }
> > >        ...
> > >        Case default:
> > >             {
> > >                 print("Command did not match any of the above");
> > >                 break;   
> > >             }
> > >      }
> > > 
> > > Kind regards,
> > > Robby Pelssers
> > >     
> > > 
> > > 
> > > -----Original Message-----
> > > From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> > > Sent: Monday, February 08, 2010 4:55 PM
> > > To: users@cocoon.apache.org
> > > Subject: Can't use switch with cocoon.request.get in flowscript
> > > 
> > > Hello,
> > >    In Cocoonn 2.1, does anyone know why I can't use a
> > switch command
> > > with the result of cocoon.request.get in flowscript?
> > > if's work just fine, but switch doesn't.  E.g. to get the 
> switch to 
> > > work I have to do the following:
> > > 
> > >      var cmd = cocoon.request.get("Cmd");
> > > 
> > >      //For some reason, the switch doesn't work with the
> > >      //string returned from cocoon.request.get, but if
> > >      //statements do.
> > >      if (cmd == "Open") {
> > >         cmd = "Open";
> > >      }
> > >      if (cmd == "Create Model") {
> > >         cmd = "Create Model";
> > >      }
> > >      if (cmd == "Account") {
> > >          cmd = "Account";
> > >       }
> > >      if (cmd == "Logout") {
> > >         cmd = "Logout";
> > >      }
> > > 
> > >      switch (cmd) {
> > > 
> > >         case "Open":
> > >                   ...
> > > 
> > > I have tried adding .toString() to the end of the get 
> function and 
> > > also the cmd variable in various places, but that doesn't
> > work either.
> > > 
> > > Thanks!
> > > Jeff
> > > 
> > > 
> > > 
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > > For additional commands, e-mail: users-help@cocoon.apache.org
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> > 
> > 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Can't use switch with cocoon.request.get in flowscript [SOLUTION]

Posted by Robby Pelssers <ro...@ciber.com>.
Hi Jeff,

I did a similar setup in  a Cocoon2.2 block and the same problem occurs:

function testSwitch() {
	var cmd = cocoon.request.getParameter("cmd");
	
	print("cmd=" + cmd);
	print(cmd.getClass().getName());
	
	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;			
	}
}


Output in console:
cmd=delete
java.lang.String
request parameter was none of the above

By the way... cmd.getClass().getName() is only possible if the object is in fact a java object.  They use LiveConnect so you can easily use Java and JavaScript together.  I suspect that the switch does not work properly on java.lang.String.

So when you convert the cmd to a native javascript object it suddenly will work again.  A better solution is demonstrated below:



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
}

Kind regards,
Robby

-----Original Message-----
From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com] 
Sent: Monday, February 08, 2010 6:59 PM
To: users@cocoon.apache.org
Subject: RE: Can't use switch with cocoon.request.get in flowscript

In effect, I already do that with the following code which is my workaround.  In this case the switch DOES work.

     var cmd = cocoon.request.get("Cmd");

     //For some reason, the switch doesn't work with the
     //string returned from cocoon.request.get, but if
     //statements do.
     if (cmd == "Open") {
        cmd = "Open";
     }
     if (cmd == "Create Model") {
        cmd = "Create Model";
     }     
     if (cmd == "Account") {
         cmd = "Account";
      } 
     if (cmd == "Logout") {
        cmd = "Logout";
     } 
     
     switch (cmd) {

        case "Open":

Jeff
Work: 314-232-1997
Cell: 636-448-5990
 

> -----Original Message-----
> From: Robby Pelssers [mailto:robby.pelssers@ciber.com] 
> Sent: Monday, February 08, 2010 11:56 AM
> To: users@cocoon.apache.org
> Subject: RE: Can't use switch with cocoon.request.get in flowscript
> 
> A next step would be to try something like 
> 
>      var cmd = "Open";
>      print("cmd='" + cmd = "'");
> 
>      switch (cmd) {
>         case "Open": 
>             {
>                 print("Command is Open");
>                 break;
>             }
>         case "Create Model": 
>             {
>                 print("Command is Create Model");
>                 break;   
>             }
>        case default:
>             {
>                 print("Command did not match any of the above");
>                 break;   
>             }
>      }
> 
> If this snippet still does print the default output you know 
> for sure the switch is not behaving properly. 
> 
> https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference
> /Statements/switch
> 
> So can you first see what the output of the snippet above is?
> 
> Cheers,
> Robby
> 
> 
> 
> -----Original Message-----
> From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> Sent: Monday, February 08, 2010 5:45 PM
> To: users@cocoon.apache.org
> Subject: RE: Can't use switch with cocoon.request.get in flowscript
> 
> Here's the output.  Very strange.  Again, 'if' check's work 
> on it, but the switch command doesn't unless I do the workaround.
> 
>  cmd='Open'
>  Command did not match any of the above
> 
> Jeff
> Work: 314-232-1997
> Cell: 636-448-5990
>  
> 
> > -----Original Message-----
> > From: Robby Pelssers [mailto:robby.pelssers@ciber.com]
> > Sent: Monday, February 08, 2010 10:27 AM
> > To: users@cocoon.apache.org
> > Subject: RE: Can't use switch with cocoon.request.get in flowscript
> > 
> > Well,
> > 
> > I know for sure the switch works fine in cocoon2.2.  Might not be 
> > implemented properly in an older version of Rhino?
> > 
> > Anyway...
> > 
> > What happens if you use this snippet??  It should at least print 
> > something to your console.
> > 
> >      var cmd = cocoon.request.get("Cmd");
> >      print("cmd='" + cmd = "'");
> > 
> >      switch (cmd) {
> >         case "Open": 
> >             {
> >                 print("Command is Open");
> >                 break;
> >             }
> >         case "Create Model": 
> >             {
> >                 print("Command is Create Model");
> >                 break;   
> >             }
> >        ...
> >        Case default:
> >             {
> >                 print("Command did not match any of the above");
> >                 break;   
> >             }
> >      }
> > 
> > Kind regards,
> > Robby Pelssers
> >     
> > 
> > 
> > -----Original Message-----
> > From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> > Sent: Monday, February 08, 2010 4:55 PM
> > To: users@cocoon.apache.org
> > Subject: Can't use switch with cocoon.request.get in flowscript
> > 
> > Hello,
> >    In Cocoonn 2.1, does anyone know why I can't use a 
> switch command 
> > with the result of cocoon.request.get in flowscript?
> > if's work just fine, but switch doesn't.  E.g. to get the switch to 
> > work I have to do the following:
> > 
> >      var cmd = cocoon.request.get("Cmd");
> > 
> >      //For some reason, the switch doesn't work with the
> >      //string returned from cocoon.request.get, but if
> >      //statements do.
> >      if (cmd == "Open") {
> >         cmd = "Open";
> >      }
> >      if (cmd == "Create Model") {
> >         cmd = "Create Model";
> >      }
> >      if (cmd == "Account") {
> >          cmd = "Account";
> >       }
> >      if (cmd == "Logout") {
> >         cmd = "Logout";
> >      }
> > 
> >      switch (cmd) {
> > 
> >         case "Open":
> >                   ...
> > 
> > I have tried adding .toString() to the end of the get function and 
> > also the cmd variable in various places, but that doesn't 
> work either.
> > 
> > Thanks!
> > Jeff
> > 
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> > 
> > 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Can't use switch with cocoon.request.get in flowscript

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
In effect, I already do that with the following code which is my workaround.  In this case the switch DOES work.

     var cmd = cocoon.request.get("Cmd");

     //For some reason, the switch doesn't work with the
     //string returned from cocoon.request.get, but if
     //statements do.
     if (cmd == "Open") {
        cmd = "Open";
     }
     if (cmd == "Create Model") {
        cmd = "Create Model";
     }     
     if (cmd == "Account") {
         cmd = "Account";
      } 
     if (cmd == "Logout") {
        cmd = "Logout";
     } 
     
     switch (cmd) {

        case "Open":

Jeff
Work: 314-232-1997
Cell: 636-448-5990
 

> -----Original Message-----
> From: Robby Pelssers [mailto:robby.pelssers@ciber.com] 
> Sent: Monday, February 08, 2010 11:56 AM
> To: users@cocoon.apache.org
> Subject: RE: Can't use switch with cocoon.request.get in flowscript
> 
> A next step would be to try something like 
> 
>      var cmd = "Open";
>      print("cmd='" + cmd = "'");
> 
>      switch (cmd) {
>         case "Open": 
>             {
>                 print("Command is Open");
>                 break;
>             }
>         case "Create Model": 
>             {
>                 print("Command is Create Model");
>                 break;   
>             }
>        case default:
>             {
>                 print("Command did not match any of the above");
>                 break;   
>             }
>      }
> 
> If this snippet still does print the default output you know 
> for sure the switch is not behaving properly. 
> 
> https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference
> /Statements/switch
> 
> So can you first see what the output of the snippet above is?
> 
> Cheers,
> Robby
> 
> 
> 
> -----Original Message-----
> From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> Sent: Monday, February 08, 2010 5:45 PM
> To: users@cocoon.apache.org
> Subject: RE: Can't use switch with cocoon.request.get in flowscript
> 
> Here's the output.  Very strange.  Again, 'if' check's work 
> on it, but the switch command doesn't unless I do the workaround.
> 
>  cmd='Open'
>  Command did not match any of the above
> 
> Jeff
> Work: 314-232-1997
> Cell: 636-448-5990
>  
> 
> > -----Original Message-----
> > From: Robby Pelssers [mailto:robby.pelssers@ciber.com]
> > Sent: Monday, February 08, 2010 10:27 AM
> > To: users@cocoon.apache.org
> > Subject: RE: Can't use switch with cocoon.request.get in flowscript
> > 
> > Well,
> > 
> > I know for sure the switch works fine in cocoon2.2.  Might not be 
> > implemented properly in an older version of Rhino?
> > 
> > Anyway...
> > 
> > What happens if you use this snippet??  It should at least print 
> > something to your console.
> > 
> >      var cmd = cocoon.request.get("Cmd");
> >      print("cmd='" + cmd = "'");
> > 
> >      switch (cmd) {
> >         case "Open": 
> >             {
> >                 print("Command is Open");
> >                 break;
> >             }
> >         case "Create Model": 
> >             {
> >                 print("Command is Create Model");
> >                 break;   
> >             }
> >        ...
> >        Case default:
> >             {
> >                 print("Command did not match any of the above");
> >                 break;   
> >             }
> >      }
> > 
> > Kind regards,
> > Robby Pelssers
> >     
> > 
> > 
> > -----Original Message-----
> > From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> > Sent: Monday, February 08, 2010 4:55 PM
> > To: users@cocoon.apache.org
> > Subject: Can't use switch with cocoon.request.get in flowscript
> > 
> > Hello,
> >    In Cocoonn 2.1, does anyone know why I can't use a 
> switch command 
> > with the result of cocoon.request.get in flowscript?
> > if's work just fine, but switch doesn't.  E.g. to get the switch to 
> > work I have to do the following:
> > 
> >      var cmd = cocoon.request.get("Cmd");
> > 
> >      //For some reason, the switch doesn't work with the
> >      //string returned from cocoon.request.get, but if
> >      //statements do.
> >      if (cmd == "Open") {
> >         cmd = "Open";
> >      }
> >      if (cmd == "Create Model") {
> >         cmd = "Create Model";
> >      }
> >      if (cmd == "Account") {
> >          cmd = "Account";
> >       }
> >      if (cmd == "Logout") {
> >         cmd = "Logout";
> >      }
> > 
> >      switch (cmd) {
> > 
> >         case "Open":
> >                   ...
> > 
> > I have tried adding .toString() to the end of the get function and 
> > also the cmd variable in various places, but that doesn't 
> work either.
> > 
> > Thanks!
> > Jeff
> > 
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> > 
> > 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Can't use switch with cocoon.request.get in flowscript

Posted by Robby Pelssers <ro...@ciber.com>.
A next step would be to try something like 

     var cmd = "Open";
     print("cmd='" + cmd = "'");

     switch (cmd) {
        case "Open": 
            {
                print("Command is Open");
                break;
            }
        case "Create Model": 
            {
                print("Command is Create Model");
                break;   
            }
       case default:
            {
                print("Command did not match any of the above");
                break;   
            }
     }

If this snippet still does print the default output you know for sure the switch is not behaving properly. 

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/switch

So can you first see what the output of the snippet above is?

Cheers,
Robby



-----Original Message-----
From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com] 
Sent: Monday, February 08, 2010 5:45 PM
To: users@cocoon.apache.org
Subject: RE: Can't use switch with cocoon.request.get in flowscript

Here's the output.  Very strange.  Again, 'if' check's work on it, but the switch command doesn't unless I do the workaround.

 cmd='Open'
 Command did not match any of the above

Jeff
Work: 314-232-1997
Cell: 636-448-5990
 

> -----Original Message-----
> From: Robby Pelssers [mailto:robby.pelssers@ciber.com] 
> Sent: Monday, February 08, 2010 10:27 AM
> To: users@cocoon.apache.org
> Subject: RE: Can't use switch with cocoon.request.get in flowscript
> 
> Well,
> 
> I know for sure the switch works fine in cocoon2.2.  Might 
> not be implemented properly in an older version of Rhino?
> 
> Anyway...
> 
> What happens if you use this snippet??  It should at least 
> print something to your console.
> 
>      var cmd = cocoon.request.get("Cmd");
>      print("cmd='" + cmd = "'");
> 
>      switch (cmd) {
>         case "Open": 
>             {
>                 print("Command is Open");
>                 break;
>             }
>         case "Create Model": 
>             {
>                 print("Command is Create Model");
>                 break;   
>             }
>        ...
>        Case default:
>             {
>                 print("Command did not match any of the above");
>                 break;   
>             }
>      }
> 
> Kind regards,
> Robby Pelssers
>     
> 
> 
> -----Original Message-----
> From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> Sent: Monday, February 08, 2010 4:55 PM
> To: users@cocoon.apache.org
> Subject: Can't use switch with cocoon.request.get in flowscript
> 
> Hello,
>    In Cocoonn 2.1, does anyone know why I can't use a switch 
> command with the result of cocoon.request.get in flowscript?  
> if's work just fine, but switch doesn't.  E.g. to get the 
> switch to work I have to do the following:
> 
>      var cmd = cocoon.request.get("Cmd");
> 
>      //For some reason, the switch doesn't work with the
>      //string returned from cocoon.request.get, but if
>      //statements do.
>      if (cmd == "Open") {
>         cmd = "Open";
>      }
>      if (cmd == "Create Model") {
>         cmd = "Create Model";
>      }
>      if (cmd == "Account") {
>          cmd = "Account";
>       }
>      if (cmd == "Logout") {
>         cmd = "Logout";
>      }
> 
>      switch (cmd) {
> 
>         case "Open":
>                   ...
> 
> I have tried adding .toString() to the end of the get 
> function and also the cmd variable in various places, but 
> that doesn't work either.
> 
> Thanks!
> Jeff
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Can't use switch with cocoon.request.get in flowscript

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
Here's the output.  Very strange.  Again, 'if' check's work on it, but the switch command doesn't unless I do the workaround.

 cmd='Open'
 Command did not match any of the above

Jeff
Work: 314-232-1997
Cell: 636-448-5990
 

> -----Original Message-----
> From: Robby Pelssers [mailto:robby.pelssers@ciber.com] 
> Sent: Monday, February 08, 2010 10:27 AM
> To: users@cocoon.apache.org
> Subject: RE: Can't use switch with cocoon.request.get in flowscript
> 
> Well,
> 
> I know for sure the switch works fine in cocoon2.2.  Might 
> not be implemented properly in an older version of Rhino?
> 
> Anyway...
> 
> What happens if you use this snippet??  It should at least 
> print something to your console.
> 
>      var cmd = cocoon.request.get("Cmd");
>      print("cmd='" + cmd = "'");
> 
>      switch (cmd) {
>         case "Open": 
>             {
>                 print("Command is Open");
>                 break;
>             }
>         case "Create Model": 
>             {
>                 print("Command is Create Model");
>                 break;   
>             }
>        ...
>        Case default:
>             {
>                 print("Command did not match any of the above");
>                 break;   
>             }
>      }
> 
> Kind regards,
> Robby Pelssers
>     
> 
> 
> -----Original Message-----
> From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com]
> Sent: Monday, February 08, 2010 4:55 PM
> To: users@cocoon.apache.org
> Subject: Can't use switch with cocoon.request.get in flowscript
> 
> Hello,
>    In Cocoonn 2.1, does anyone know why I can't use a switch 
> command with the result of cocoon.request.get in flowscript?  
> if's work just fine, but switch doesn't.  E.g. to get the 
> switch to work I have to do the following:
> 
>      var cmd = cocoon.request.get("Cmd");
> 
>      //For some reason, the switch doesn't work with the
>      //string returned from cocoon.request.get, but if
>      //statements do.
>      if (cmd == "Open") {
>         cmd = "Open";
>      }
>      if (cmd == "Create Model") {
>         cmd = "Create Model";
>      }
>      if (cmd == "Account") {
>          cmd = "Account";
>       }
>      if (cmd == "Logout") {
>         cmd = "Logout";
>      }
> 
>      switch (cmd) {
> 
>         case "Open":
>                   ...
> 
> I have tried adding .toString() to the end of the get 
> function and also the cmd variable in various places, but 
> that doesn't work either.
> 
> Thanks!
> Jeff
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Can't use switch with cocoon.request.get in flowscript

Posted by Robby Pelssers <ro...@ciber.com>.
Well,

I know for sure the switch works fine in cocoon2.2.  Might not be implemented properly in an older version of Rhino?

Anyway...

What happens if you use this snippet??  It should at least print something to your console.

     var cmd = cocoon.request.get("Cmd");
     print("cmd='" + cmd = "'");

     switch (cmd) {
        case "Open": 
            {
                print("Command is Open");
                break;
            }
        case "Create Model": 
            {
                print("Command is Create Model");
                break;   
            }
       ...
       Case default:
            {
                print("Command did not match any of the above");
                break;   
            }
     }

Kind regards,
Robby Pelssers
    


-----Original Message-----
From: Schmitz, Jeffrey A [mailto:Jeffrey.A.Schmitz@boeing.com] 
Sent: Monday, February 08, 2010 4:55 PM
To: users@cocoon.apache.org
Subject: Can't use switch with cocoon.request.get in flowscript

Hello,
   In Cocoonn 2.1, does anyone know why I can't use a switch command with the result of cocoon.request.get in flowscript?  if's work just fine, but switch doesn't.  E.g. to get the switch to work I have to do the following:

     var cmd = cocoon.request.get("Cmd");

     //For some reason, the switch doesn't work with the
     //string returned from cocoon.request.get, but if
     //statements do.
     if (cmd == "Open") {
        cmd = "Open";
     }
     if (cmd == "Create Model") {
        cmd = "Create Model";
     }
     if (cmd == "Account") {
         cmd = "Account";
      }
     if (cmd == "Logout") {
        cmd = "Logout";
     }

     switch (cmd) {

        case "Open":
                  ...

I have tried adding .toString() to the end of the get function and also the cmd variable in various places, but that doesn't work either.

Thanks!
Jeff




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org