Search in sources :

Example 1 with ScriptVariableScope

use of com.servoy.j2db.scripting.ScriptVariableScope in project servoy-client by Servoy.

the class ServoyFunctionPropertyType method nativeFunctionToJSON.

private void nativeFunctionToJSON(NativeFunction function, Map<String, Object> map) throws Exception {
    String functionName = function.getFunctionName();
    Scriptable parentScope = function.getParentScope();
    while (parentScope != null && !(parentScope instanceof ScriptVariableScope)) {
        parentScope = parentScope.getParentScope();
    }
    if (parentScope instanceof FormScope && ((FormScope) parentScope).getFormController() != null) {
        String formName = ((FormScope) parentScope).getFormController().getName();
        map.put("script", SecuritySupport.encrypt(Settings.getInstance(), "forms." + formName + "." + functionName + "()"));
        map.put("formname", formName);
    } else if (parentScope instanceof GlobalScope) {
        map.put("script", SecuritySupport.encrypt(Settings.getInstance(), "scopes." + ((GlobalScope) parentScope).getScopeName() + "." + functionName + "()"));
    }
}
Also used : GlobalScope(com.servoy.j2db.scripting.GlobalScope) ScriptVariableScope(com.servoy.j2db.scripting.ScriptVariableScope) Scriptable(org.mozilla.javascript.Scriptable) FormScope(com.servoy.j2db.scripting.FormScope)

Aggregations

FormScope (com.servoy.j2db.scripting.FormScope)1 GlobalScope (com.servoy.j2db.scripting.GlobalScope)1 ScriptVariableScope (com.servoy.j2db.scripting.ScriptVariableScope)1 Scriptable (org.mozilla.javascript.Scriptable)1