# Help with WebClientUtils

**URL:** <https://forum.servoy.com/t/help-with-webclientutils/11367>\
**Category:** Classic Servoy\
**Created:** [November 5, 2009, 10:45am UTC](https://forum.servoy.com/t/help-with-webclientutils/11367 "2009-11-05T10:45:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [November 5, 2009, 10:45am UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/1 "2009-11-05T10:45:01Z")

</div>

I am trying to return a clientside value to a callback method using the WebClientUtils plugin.

Using the sample code I can trigger the callback method but have not found a way to pass a value back to it. Using this code…

```auto
var jsToExecute = "var sum = 1 + 2";
plugins.WebClientUtils.executeClientSideJS(jsToExecute, globals.callBackMethod(), ['sum'])

```

… the callBackMethod triggers fine but I can’t retrieve the value in ‘sum’ as an argument passed into the callback method ![:-(]( "Sad"). Can anyone tell me where I am going wrong? Or does this not work in 3.5?

Servoy Developer  
Version 3.5.10-build 524  
Java version 1.5.0\_20-141 (Mac OS X)

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 5, 2009, 12:30pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/2 "2009-11-05T12:30:24Z")

</div>

Hi David,

I have no experience with this plugin but I think you are using the wrong syntax to pass the method.  
When you pass the method with parenthesis at the end you are in fact triggering it right there and then instead of passing the method object.  
So try the following code:

```auto
var jsToExecute = "var sum = 1 + 2";
plugins.WebClientUtils.executeClientSideJS(jsToExecute, globals.callBackMethod, ['sum'])

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [November 5, 2009, 3:02pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/3 "2009-11-05T15:02:21Z")

</div>

Hi Robert,

Good suggestion. Unfortunately if I take the parentheses off then nothing happens - the callback method does not trigger at all. Of course, with the parentheses there I do not know if it triggering immediately or correctly in sequence after the clientside javascript has executed!

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 5, 2009, 3:25pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/4 "2009-11-05T15:25:13Z")

</div>

Hi David,

And you are sure you’re don’t need to pass the method name as a String ?

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [November 5, 2009, 4:12pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/5 "2009-11-05T16:12:48Z")

</div>

That generates an error in the log:

> org.mozilla.javascript.EvaluatorException: Can’t find method com.servoy.plugins.WebClientPlugin.js\_executeClientSideJS(string,string,[Ljava.lang.Object;).

Incidentally I now see that if I include the parentheses (but not in a string) that also generates an error:

> org.mozilla.javascript.EvaluatorException: Can’t find method com.servoy.plugins.WebClientPlugin.js\_executeClientSideJS(string,undefined,[Ljava.lang.Object;).

With no parentheses and no string there is no error in the log but still the method does not execute. Must be missing something still ![:?]( "Confused")

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 5, 2009, 4:21pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/6 "2009-11-05T16:21:40Z")

</div>

Hi David,

You are sure the method is not triggered when you pass it without the quotes and parenthesis ? Also I see you pass the sum as a string ‘sum’ and not the variable sum.

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [November 5, 2009, 4:33pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/7 "2009-11-05T16:33:38Z")

</div>

> You are sure the method is not triggered when you pass it without the quotes and parenthesis ?

For testing I use a simple method to find and load a record, then set the value in a field (I was trying to use the returned value!) - the record is not changed so I assume the method isn’t executing at all.

> Also I see you pass the sum as a string ‘sum’ and not the variable sum.

Seems to require that - if I try without the inverted commas i.e. ```  
plugins.WebClientUtils.executeClientSideJS(jsToExecute, globals.callBackMethod, [sum])

```then

> ReferenceError: "sum" is not defined.
```

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 5, 2009, 4:51pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/8 "2009-11-05T16:51:14Z")

</div>

Hi David,

And if you just set a hardcoded value? Just to see if the method triggers or not.  
Also where do you get this plugin ? Google seems oblivious of it.  
I seem to remember that Scott or Sean made this one.

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [November 5, 2009, 4:59pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/9 "2009-11-05T16:59:52Z")

</div>

Hi Robert,

If I set the method to do something that does not rely on the returned value i.e. set field to ‘Hello’, still nothing happens so I’m pretty sure it’s not triggering.

Got the plugin from a link posted in this topic: [http://www.servoy.com/forum/viewtopic.php?f=34&t=13205](http://www.servoy.com/forum/viewtopic.php?f=34&t=13205). The link was posted by Scott and Sean indeed made the plugin.

Direct link to plugin: [Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/web-client-utils/downloads/list)

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 5, 2009, 5:16pm UTC](https://forum.servoy.com/t/help-with-webclientutils/11367/10 "2009-11-05T17:16:06Z")

</div>

I am looking at the example code which is exactly what you are using and I think Sean is the one that needs to answer this one.
