DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR
{column:width=80px|padding=0px}{column}{column}{column}
Constants Summary
CALLBACK_EVENT
Constant that is returned as a JSEvent type when in the callback method when it executed normally.
CALLBACK_EXCEPTION_EVENT
Constant that is returned as a JSEvent type when in the callback method when an exception occurred.
{column:width=80px|padding=0px}{column}{column}{column}
Method Summary
getClientID()
Gets the id of the client.
getDataProviderValue(contextName, dataprovider)
Get a data-provider value.
getDataProviderValue(contextName, dataprovider, methodName)
Get a data-provider value.
void
queueMethod(contextName, methodName, args, notifyCallBackMethod)
Queues a method call on the remote server.
setDataProviderValue(contextName, dataprovider, value)
Set a data-provider value.
setDataProviderValue(contextName, dataprovider, value, methodName)
Set a data-provider value.
{column:width=100%|padding=0px}{column}
Constants Details
Sample
if (jsclient && jsclient.isValid()) { /*Queue a method where the callback can do something like this if (event.getType() == JSClient.CALLBACK_EVENT) { application.output("callback data, name: " + event.data); } else if (event.getType() == JSClient.CALLBACK_EXCEPTION_EVENT) { application.output("exception callback, name: " + event.data); }*/ var x = new Object(); x.name = 'remote1'; x.number = 10; // this calls a 'remoteMethod' on the server as a global method, because the context (first argument is set to null), you can use a formname to call a form method jsclient.queueMethod(null, "remoteMethod", [x], callback); }
Sample
if (jsclient && jsclient.isValid()) { /*Queue a method where the callback can do something like this if (event.getType() == JSClient.CALLBACK_EVENT) { application.output("callback data, name: " + event.data); } else if (event.getType() == JSClient.CALLBACK_EXCEPTION_EVENT) { application.output("exception callback, name: " + event.data); }*/ var x = new Object(); x.name = 'remote1'; x.number = 10; // this calls a 'remoteMethod' on the server as a global method, because the context (first argument is set to null), you can use a formname to call a form method jsclient.queueMethod(null, "remoteMethod", [x], callback); }
{column:width=100%|padding=0px}{column}
Method Details
getClientID
()
Sample
var headlessClient = plugins.headlessclient.createClient("someSolution", "user", "pass", null); var clientID = headlessClient.getClientID() .... headlessClient = plugins.headlessclient.getClient(clientID); if (headlessClient != null && headlessClient.isValid()) { headlessClient.queueMethod(null, "someRemoteMethod", null, callback); }
getDataProviderValue
(contextName, dataprovider)
Sample
if (jsclient && jsclient.isValid()) { // only gets the globals.media when the 'remoteMethod' is currently executing for this client var value = jsclient.getDataProviderValue(null, "scopes.globals.number", 'remoteMethod'); if (value != null) { application.output("value get from scopes.globals.number :: "+ value); scopes.globals.value = value+10; var returnValue = jsclient.setDataProviderValue(null, "scopes.globals.number", scopes.globals.value, 'remoteMethod'); application.output("value set to scopes.globals.number previous value "+ returnValue); } else { application.output("value get from scopes.globals.number :: " + null); } }
getDataProviderValue
(contextName, dataprovider, methodName)
Parameters
{String} contextName – The context of the given method; null if it is global method or a form name for a form method.
{String} dataprovider – the data-provider name as seen in Servoy.
{String} methodName – if this is specified, the data-provider's value will only be returned if the specified method is running in this headless client because the currently running client requested it to. Otherwise undefined is returned.
Sample
if (jsclient && jsclient.isValid()) { // only gets the globals.media when the 'remoteMethod' is currently executing for this client var value = jsclient.getDataProviderValue(null, "scopes.globals.number", 'remoteMethod'); if (value != null) { application.output("value get from scopes.globals.number :: "+ value); scopes.globals.value = value+10; var returnValue = jsclient.setDataProviderValue(null, "scopes.globals.number", scopes.globals.value, 'remoteMethod'); application.output("value set to scopes.globals.number previous value "+ returnValue); } else { application.output("value get from scopes.globals.number :: " + null); } }
isValid
()
Sample
if (jsclient && jsclient.isValid()) { /*Queue a method where the callback can do something like this if (event.getType() == JSClient.CALLBACK_EVENT) { application.output("callback data, name: " + event.data); } else if (event.getType() == JSClient.CALLBACK_EXCEPTION_EVENT) { application.output("exception callback, name: " + event.data); }*/ var x = new Object(); x.name = 'remote1'; x.number = 10; // this calls a 'remoteMethod' on the server as a global method, because the context (first argument is set to null), you can use a formname to call a form method jsclient.queueMethod(null, "remoteMethod", [x], callback); }
void
queueMethod
(contextName, methodName, args, notifyCallBackMethod)
Parameters
{String} contextName – The context of the given method, null if it is global method or a form name for a form method.
{String} methodName – The method name.
{Object[]} args – The arguments that should be passed to the method.
{Function} notifyCallBackMethod – The callback method that is called when the execution is finished.
Returns
void
Sample
if (jsclient && jsclient.isValid()) { /*Queue a method where the callback can do something like this if (event.getType() == JSClient.CALLBACK_EVENT) { application.output("callback data, name: " + event.data); } else if (event.getType() == JSClient.CALLBACK_EXCEPTION_EVENT) { application.output("exception callback, name: " + event.data); }*/ var x = new Object(); x.name = 'remote1'; x.number = 10; // this calls a 'remoteMethod' on the server as a global method, because the context (first argument is set to null), you can use a formname to call a form method jsclient.queueMethod(null, "remoteMethod", [x], callback); }
setDataProviderValue
(contextName, dataprovider, value)
Sample
if (jsclient && jsclient.isValid()) { // only gets the globals.media when the 'remoteMethod' is currently executing for this client var value = jsclient.getDataProviderValue(null, "scopes.globals.number", 'remoteMethod'); if (value != null) { application.output("value get from scopes.globals.number :: "+ value); scopes.globals.value = value+10; var returnValue = jsclient.setDataProviderValue(null, "scopes.globals.number", scopes.globals.value, 'remoteMethod'); application.output("value set to scopes.globals.number previous value "+ returnValue); } else { application.output("value get from scopes.globals.number :: " + null); } }
setDataProviderValue
(contextName, dataprovider, value, methodName)
Parameters
{String} contextName – The context of the given method, null if it is global method or a form name for a form method
{String} dataprovider – the data-provider name as seen in Servoy
{Object} value – the value to set
{String} methodName – if this is specified, the data-provider's value will only be set if the specified method is running in this headless client because the currently running client requested it to. Otherwise the value is not set into the data-provider and undefined is returned.
Sample
if (jsclient && jsclient.isValid()) { // only gets the globals.media when the 'remoteMethod' is currently executing for this client var value = jsclient.getDataProviderValue(null, "scopes.globals.number", 'remoteMethod'); if (value != null) { application.output("value get from scopes.globals.number :: "+ value); scopes.globals.value = value+10; var returnValue = jsclient.setDataProviderValue(null, "scopes.globals.number", scopes.globals.value, 'remoteMethod'); application.output("value set to scopes.globals.number previous value "+ returnValue); } else { application.output("value get from scopes.globals.number :: " + null); } }
void
shutdown
()
Returns
void
Sample
if (jsclient && jsclient.isValid()) { /*Queue a method where the callback can do something like this if (event.getType() == JSClient.CALLBACK_EVENT) { application.output("callback data, name: " + event.data); } else if (event.getType() == JSClient.CALLBACK_EXCEPTION_EVENT) { application.output("exception callback, name: " + event.data); }*/ var x = new Object(); x.name = 'remote1'; x.number = 10; // this calls a 'remoteMethod' on the server as a global method, because the context (first argument is set to null), you can use a formname to call a form method jsclient.queueMethod(null, "remoteMethod", [x], callback); }
void
shutdown
(force)
Returns
void
Sample
if (jsclient && jsclient.isValid()) { /*Queue a method where the callback can do something like this if (event.getType() == JSClient.CALLBACK_EVENT) { application.output("callback data, name: " + event.data); } else if (event.getType() == JSClient.CALLBACK_EXCEPTION_EVENT) { application.output("exception callback, name: " + event.data); }*/ var x = new Object(); x.name = 'remote1'; x.number = 10; // this calls a 'remoteMethod' on the server as a global method, because the context (first argument is set to null), you can use a formname to call a form method jsclient.queueMethod(null, "remoteMethod", [x], callback); }