All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.contextfw.web.application.component.FunctionCall Maven / Gradle / Ivy

package net.contextfw.web.application.component;


/**
 * Defines a javascript call invoked from server side.
 * 
 * 

* This class is a convinience class to make calls in with correct convention. *

*

* The call will be in form: functionName([args,...]); *

*/ public class FunctionCall extends Script { private final String function; private final Object[] args; public FunctionCall(String function, Object... args) { this.function = function; this.args = args; } protected static String toScript(String function, int argCount) { StringBuilder b = new StringBuilder(function).append("("); String delim = ""; for (int i = 0; i < argCount; i++) { b.append(delim).append("{").append(i).append("}"); delim = ","; } b.append(");\n"); return b.toString(); } @Override public String getScript(ScriptContext scriptContext) { return FunctionCall.toScript(getFunctionName(scriptContext), args == null ? 0 : args.length); } @Override public Object[] getArguments(ScriptContext scriptContext) { return args; } /** * Override this, if function name is determined lazily. * @return */ protected String getFunctionName(ScriptContext scriptContext) { return function; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy