Eval and Webclient

Using Servoy to administrate the content of your website? Discuss all webrelated Servoy topics on this forum!

Eval and Webclient

Postby erdione » Wed Jun 10, 2009 11:44 am

the eval in webclient procude different behaviour between two servers:

Server Dev
JDK Information
java.vm.name=Java HotSpot(TM) Client VM
java.vm.version=11.0-b16
java.vm.info=mixed mode, sharing
java.vm.vendor=Sun Microsystems Inc.
Operating System Information
os.name=Windows 2003
os.version=5.2
os.arch=x86
Everything is ok

Prod Server
JDK Information
java.vm.name=Java HotSpot(TM) Client VM
java.vm.version=11.3-b02
java.vm.info=mixed mode, sharing
java.vm.vendor=Sun Microsystems Inc.
Operating System Information
os.name=Windows 2003
os.version=5.2
os.arch=x86
I've got couldn't eval the string ...

Do you have any idea ?
Fabrice
erdione
 
Posts: 112
Joined: Thu Feb 01, 2007 1:19 pm

Re: Eval and Webclient

Postby IT2Be » Wed Jun 10, 2009 11:51 am

And what is your question?
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Re: Eval and Webclient

Postby erdione » Wed Jun 10, 2009 11:57 am

Sorry the question wasn't really clear

I've got "couldn't eval the string ..." in the prod server log

Did you already have any strange eval behaviour between two java version ?
Fabrice
erdione
 
Posts: 112
Joined: Thu Feb 01, 2007 1:19 pm

Re: Eval and Webclient

Postby martinh » Wed Jun 10, 2009 5:28 pm

I noticed also a problem with eval()

I already created an issue in the support database. Case 217097

In Eclipse I get the following error:

Source not found for module [C:/Users/Martin/servoy_workspace_development/MOD_RSS_HTMLTree/globals.js#645(eval): 1]
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Eval and Webclient

Postby jcompagner » Thu Jun 11, 2009 9:54 am

what are you trying to eval?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Eval and Webclient

Postby erdione » Thu Jun 11, 2009 10:07 am

Ive got mostly the error when i try to eval
myvariable = globals.myfunction()
or
myvariable = globals.myfunction('arg1','arg2')
Fabrice
erdione
 
Posts: 112
Joined: Thu Feb 01, 2007 1:19 pm

Re: Eval and Webclient

Postby martinh » Thu Jun 11, 2009 10:15 am

Johan,

See my case 217097. I added some coding how I tried to eval.

I use eval() in several ways:

Code: Select all
str = 'globals.myMethod'
if (eval(str))  // To test if method exists
{
eval(str)(args)
}


But also

Code: Select all
str = 'globals.myVar'
if (eval(str) == 1) // To test if this variable has value 1


And also

Code: Select all
str = 'globals.myVar'
if (some test)
  str += ' = 1'
else
str += ' = 2';
eval(str)  // Set variable to 1 or 2


And also

Code: Select all
str = 'globals.myVar'
if (some test)
  str += ' [1]'
else
str += ' [2]';
str += ' = 3'
eval(str) // Give some array value the value 3


Of course these example are quite simple, but it shows the way eval() is used. I worked fine in 3.5 and some of the coding was originally written in 2.2!

By the way, I tried also the following and that is working, so it looks like it is perhaps eval() in combination with if-statement

Code: Select all
str = 'globals.myVar'
val = eval(str)
if (val == 1) // To test if this variable has value 1
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Eval and Webclient

Postby jcompagner » Thu Jun 11, 2009 10:23 am

erdione wrote:Ive got mostly the error when i try to eval
myvariable = globals.myfunction()
or
myvariable = globals.myfunction('arg1','arg2')


so you are doing

eval("myvariable = globals.myfunction()");

why would you eval that?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Eval and Webclient

Postby jcompagner » Thu Jun 11, 2009 10:26 am

martinh wrote:Johan,

See my case 217097. I added some coding how I tried to eval.

I use eval() in several ways:


why are you evalling that kind of stuff like that?

why not just

if (globals['mymethod'])
{
globals['mymethod'](args)
}

way faster then evalling.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Eval and Webclient

Postby erdione » Thu Jun 11, 2009 10:30 am

I eval that because for example myfunction can be dynamically change (in my case database driven)
Fabrice
erdione
 
Posts: 112
Joined: Thu Feb 01, 2007 1:19 pm

Re: Eval and Webclient

Postby jcompagner » Thu Jun 11, 2009 11:01 am

Code: Select all
myvariable = globals[dynamicname]();


should work fine and even better/faster.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Eval and Webclient

Postby martinh » Thu Jun 11, 2009 11:03 am

jcompagner wrote:
martinh wrote:Johan,

See my case 217097. I added some coding how I tried to eval.

I use eval() in several ways:


why are you evalling that kind of stuff like that?

why not just

if (globals['mymethod'])
{
globals['mymethod'](args)
}

way faster then evalling.


Because mymethod is a variable name (callback method)
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Eval and Webclient

Postby jcompagner » Thu Jun 11, 2009 11:27 am

Code: Select all
globals[variableHoldingTheNameOfTheMethodYouWantToCall]()



really guys, eval is almost never needed..
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Eval and Webclient

Postby martinh » Thu Jun 11, 2009 11:55 am

OK, I'll see if I can change my code, but how about the following:

Code: Select all
var _method = arguments[0];

if (eval(_method))
{
   eval(_method)()
}


And the argument that I get, is a method on a form

So Arguments 0 = forms.myForm.myMethod
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Eval and Webclient

Postby jcompagner » Thu Jun 11, 2009 12:02 pm

Code: Select all
function test()
{
   var name = "called"; // arguments[0];
   var argument = "from test";
   this[name](argument);
}

function called()
{
   application.output("called with argument: " + arguments[0])
}
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Web Development

Who is online

Users browsing this forum: No registered users and 3 guests