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…
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 . 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)
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:
var jsToExecute = "var sum = 1 + 2";
plugins.WebClientUtils.executeClientSideJS(jsToExecute, globals.callBackMethod, ['sum'])
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!
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.
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])
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.
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.