Yet another javascript integration question. I have no idea know how to return a value from my java method to use it in the javascript code. Can you help?
{
//My java method
JSObject dataObj = (JSObject) ctx.get("{}");
dataObj.set("length", new JSFunction() {
@Override
public void apply(JSObject self, Object[] args) {
/*
Here, say I want to return the string length.
return args[0].toString().length();
*/
}
});
ctx.set("window.java", dataObj);
}
{
String fn = "{ uf : function(a){ var l = java.length(a);}}";
JSObject obj = (JSObject) ctx.get(fn);
Object result = obj.call("uf", new Object[] {"Hello"});
}
Thanks a lot.
E