Weslei
(Weslei Dias)
November 3, 2016, 11:50am
1
Hi,
I’m using AbstractJavaScriptComponent and the callFuntion(“function”) to execute the js.
I cant´t get the return value the function
Example:
this.exibirPassageiros = function(jsonStringCliques, distanciaMaxima) {
...
return listaPassageiros;
}
I call the function using RPC
callFunction(“exibirPassageiros”, cliquesJson.toString(), distanciaMaxima.doubleValue());
How can i get the return value?
Alain42
(Alain HIRSCH)
November 3, 2016, 12:12pm
2
you can by calling a function from the server side in your js.
example server side register the function:
addFunction("getExibirPassageiros ", new JavaScriptFunction() {
@Override
public void call(JsonArray arguments) {
//retrieve listaPassageiros : index 0 of arguments
}
});
and then call it on js side:
this.exibirPassageiros = function(jsonStringCliques, distanciaMaxima) {
...
//Execute the method in server side
self.getExibirPassageiros(listaPassageiros)
}
Weslei
(Weslei Dias)
November 3, 2016, 1:57pm
3
you can by calling a function from the server side in your js.
example server side register the function:
addFunction("getExibirPassageiros ", new JavaScriptFunction() {
@Override
public void call(JsonArray arguments) {
//retrieve listaPassageiros : index 0 of arguments
}
});
and then call it on js side:
this.exibirPassageiros = function(jsonStringCliques, distanciaMaxima) {
...
//Execute the method in server side
self.getExibirPassageiros(listaPassageiros)
}
How can i pass the arguments to the function?
Alain42
(Alain HIRSCH)
November 3, 2016, 2:12pm
4
just pass it in javascript.
self.getExibirPassageiros(listaPassageiros)
this will invoke your server method with the argument with the value of your listaPassageiros variable
in server side you just get it.
Assume it is a String :
and get it that way. If other type change it
addFunction("getExibirPassageiros ", new JavaScriptFunction() {
@Override
public void call(JsonArray arguments) {
String txtReturn = arguments.getString(0);
}
});
Weslei
(Weslei Dias)
November 3, 2016, 3:00pm
5
just pass it in javascript.
self.getExibirPassageiros(listaPassageiros)
this will invoke your server method with the argument with the value of your listaPassageiros variable
in server side you just get it.
Assume it is a String :
and get it that way. If other type change it
addFunction("getExibirPassageiros ", new JavaScriptFunction() {
@Override
public void call(JsonArray arguments) {
String txtReturn = arguments.getString(0);
}
});
Thanks man, it works perfectly!!!