Search in sources :

Example 36 with ScriptMethod

use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.

the class JSForm method js_setOnSortCmdMethod.

/**
 * @deprecated As of release 4.1, replaced by setOnSortCmd(JSMethod).
 */
@Deprecated
public void js_setOnSortCmdMethod(Object functionOrInteger) {
    checkModification();
    if (functionOrInteger instanceof Function) {
        Function function = (Function) functionOrInteger;
        ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
        if (scriptMethod != null) {
            getForm().setOnSortCmdMethodID(scriptMethod.getID());
        } else {
            getForm().setOnSortCmdMethodID(0);
        }
    } else if (functionOrInteger instanceof Number) {
        getForm().setOnSortCmdMethodID(((Number) functionOrInteger).intValue());
    }
}
Also used : JSFunction(org.mozilla.javascript.annotations.JSFunction) Function(org.mozilla.javascript.Function) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod)

Example 37 with ScriptMethod

use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.

the class JSForm method js_setOnUnLoadMethod.

/**
 * @deprecated As of release 4.1, replaced by setOnUnLoad(JSMethod).
 */
@Deprecated
public void js_setOnUnLoadMethod(Object functionOrInteger) {
    checkModification();
    if (functionOrInteger instanceof Function) {
        Function function = (Function) functionOrInteger;
        ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
        if (scriptMethod != null) {
            getForm().setOnUnLoadMethodID(scriptMethod.getID());
        } else {
            getForm().setOnUnLoadMethodID(0);
        }
    } else if (functionOrInteger instanceof Number) {
        getForm().setOnUnLoadMethodID(((Number) functionOrInteger).intValue());
    }
}
Also used : JSFunction(org.mozilla.javascript.annotations.JSFunction) Function(org.mozilla.javascript.Function) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod)

Example 38 with ScriptMethod

use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.

the class JSForm method getMethods.

/**
 * Returns all existing form methods for this form.
 *
 * @sample
 * var frm = solutionModel.getForm("myForm");
 * var methods = frm.getMethods();
 * for (var m in methods)
 * 	application.output(methods[m].getName());
 *
 * @param returnInheritedElements boolean true to also return the elements from the parent form
 * @return all form methods for the form
 */
@JSFunction
public JSMethod[] getMethods(boolean returnInheritedElements) {
    List<JSMethod> methods = new ArrayList<JSMethod>();
    Form form2use = returnInheritedElements ? getFlattenedContainer() : getForm();
    Iterator<ScriptMethod> scriptMethods = form2use.getScriptMethods(true);
    while (scriptMethods.hasNext()) {
        methods.add(new JSMethod(this, scriptMethods.next(), application, false));
    }
    return methods.toArray(new JSMethod[methods.size()]);
}
Also used : Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IMobileSMForm(com.servoy.base.solutionmodel.mobile.IMobileSMForm) ArrayList(java.util.ArrayList) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 39 with ScriptMethod

use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.

the class JSForm method js_setOnPrintPreviewCmdMethod.

/**
 * @deprecated As of release 4.1, replaced by setOnPrintPreviewCmd(JSMethod).
 */
@Deprecated
@ServoyClientSupport(ng = false, wc = true, sc = true)
public void js_setOnPrintPreviewCmdMethod(Object functionOrInteger) {
    checkModification();
    if (functionOrInteger instanceof Function) {
        Function function = (Function) functionOrInteger;
        ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
        if (scriptMethod != null) {
            getForm().setOnPrintPreviewCmdMethodID(scriptMethod.getID());
        } else {
            getForm().setOnPrintPreviewCmdMethodID(0);
        }
    } else if (functionOrInteger instanceof Number) {
        getForm().setOnPrintPreviewCmdMethodID(((Number) functionOrInteger).intValue());
    }
}
Also used : JSFunction(org.mozilla.javascript.annotations.JSFunction) Function(org.mozilla.javascript.Function) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod) ServoyClientSupport(com.servoy.base.scripting.annotations.ServoyClientSupport)

Example 40 with ScriptMethod

use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.

the class JSForm method js_setOnLoadMethod.

/**
 * @deprecated As of release 4.1, replaced by setOnLoad(JSMethod).
 */
@Deprecated
public void js_setOnLoadMethod(Object functionOrInteger) {
    checkModification();
    if (functionOrInteger instanceof Function) {
        Function function = (Function) functionOrInteger;
        ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
        if (scriptMethod != null) {
            getForm().setOnLoadMethodID(scriptMethod.getID());
        } else {
            getForm().setOnLoadMethodID(0);
        }
    } else if (functionOrInteger instanceof Number) {
        getForm().setOnLoadMethodID(((Number) functionOrInteger).intValue());
    }
}
Also used : JSFunction(org.mozilla.javascript.annotations.JSFunction) Function(org.mozilla.javascript.Function) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod)

Aggregations

ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)55 JSFunction (org.mozilla.javascript.annotations.JSFunction)31 Function (org.mozilla.javascript.Function)27 FlattenedSolution (com.servoy.j2db.FlattenedSolution)14 Solution (com.servoy.j2db.persistence.Solution)14 RepositoryException (com.servoy.j2db.persistence.RepositoryException)12 Form (com.servoy.j2db.persistence.Form)11 TableNode (com.servoy.j2db.persistence.TableNode)9 ServoyException (com.servoy.j2db.util.ServoyException)8 ArrayList (java.util.ArrayList)7 GlobalScope (com.servoy.j2db.scripting.GlobalScope)6 Scriptable (org.mozilla.javascript.Scriptable)5 IMobileSMForm (com.servoy.base.solutionmodel.mobile.IMobileSMForm)4 ISMForm (com.servoy.j2db.solutionmodel.ISMForm)4 ServoyClientSupport (com.servoy.base.scripting.annotations.ServoyClientSupport)3 ApplicationException (com.servoy.j2db.ApplicationException)3 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)3 IPersist (com.servoy.j2db.persistence.IPersist)3 ISupportChilds (com.servoy.j2db.persistence.ISupportChilds)3 FormScope (com.servoy.j2db.scripting.FormScope)3