compute: function(value) { return value * 2; }or:
function compute(value) { return value * 2; }
helloWorld: function() { alert("Im am here"!); return 10; }and also properties, such as for example:
getLabel: function(identifier) { return document.getElementById(identifier).label; }
Script
interface:public interface Script { public int execute(); }To create the wrapper, you must use a JSScriptWrapper:
ScriptWrapper<Script> wrapper = new JSScriptWrapper<Script>(){ }; Script script = wrapper.getScript(); File file = new File(<our script file>); wrapper.installScript(file); int value = script.execute();You can use for example the following script:
execute: function() { return 10; }Or for example this one using an internal function:
execute: function() { return this.getValue(); } getValue: function() { return 10; }
public interface Script { public int execute(); }Installing the following script will not raise any exception:
function toto() { return 1; }However, the JSScriptWrapper.setCompilerIsStrict(boolean) method allows the compiler to be stricter about the methods encountered in the script:
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence