Child pages
  • JSClient

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Divcache
Div
iddescription
HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Summary
Table Row (tr)
Table Cell (td)
String
Table Cell (td)CALLBACK_EVENT
styleindexdisplay:none

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.

true
refresh100d
showRefreshtrue
iddoc
titleRefresh page
showDatetrue
retryEnable

servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClient

servoy sSummary12%30%58%height: 30px;3Constants SummaryConstant that is returned as a JSEvent type when in the callback method when it executed normally. Table Row (tr)

Table Cell (td)
String
Table Cell (td)CALLBACK_EXCEPTION_EVENT
Constant that is returned as a JSEvent type when in the callback method when an exception occurred.table

idclassservoy sSummary

Colgroup Tag
Col
width80px
Col
Table Head (thead) Table Row (tr)style Table Row (tr)
Table Cell (td)
String
Table Cell (td)getClientID()
servoy sSummary12%30%58%height: 30px;
Table Head (th)
colspan2
Method Summary
Table Cell (td)getDataProviderValue(contextName, dataprovider)
3Methods SummaryGets the id of the client. Table Row (tr)
Table Cell (td)
Object
Get a data-provider value. Table Row (tr)
Table Cell (td)
Object
Table Cell (td)getDataProviderValue(contextName, dataprovider, methodName)
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)isValid()
Get a data-provider value.returns true if this client is still valid/usable. Table Row (tr)
Table Cell (td)
void
Table Cell (td)queueMethod(contextName, methodName, args, notifyCallBackMethod)
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)setDataProviderValue(contextName, dataprovider, value)
voidQueues a method call on the remote server, without a callback method.voidQueues a method call on the remote server.Set a data-provider value. Table Row (tr)
Table Cell (td)
Object
Table Cell (td)setDataProviderValue(contextName, dataprovider, value, methodName)
Table Row (tr) Table Cell (td)Set a data-provider value. Table Cell (td)shutdown()
voidcloses the client. Table Row (tr) Table Cell (td) Table Cell (td)shutdown(force)
voidcloses the client.table

id

constantclass Colgroup Tag Colcolspanservoy sDetail2width100%

Col
Table Head (thead) Table Row (tr)styleheight:30px; Table Head (th)colspan2idConstants Details Table Body (tbody)idCALLBACK_EVENT Table Row (tr)name

Table Cell (td)id

CALLBACK_EVENT

Table Row (tr)des Table Cell (td) DivclassidsIndent
Constant that is returned as a JSEvent type when in the callback method when it executed normally.
Table Row (tr)tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
String Table Row (tr)
idsam
Table Body (tbody)idSmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
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);
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
sIdentjavascriptlastDetailRowCALLBACK_EXCEPTION_EVENT Table Row (tr)idname

Table Cell (td)id

CALLBACK_EXCEPTION_EVENT

Table Row (tr)classdes Table Cell (td) DivsIndent
Constant that is returned as a JSEvent type when in the callback method when an exception occurred.
tr
idtdret

Returns

divsIndentclients

classid

Supported Clients

sIndent
String Table Row (tr)SmartClient,WebClient,NGClientsam

Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
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);
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idgetClientID
Table Row (tr)
idname
Table Cell (td)

getClientID

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getClientID
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

Gets the id of the client.

This client id can be used to find the client from the headless client plugin.
Note that this client id is not the same id as the id displayed on the Aplicationb Server admin page.

Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
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);
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetDataProviderValue-String_String
Table Row (tr)
idname
Table Cell (td)

getDataProviderValue

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Object
Span
stylefont-weight: bold;
getDataProviderValue
Span
(contextName, dataprovider)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get a data-provider value.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} contextName - sIdentjavascriptlastDetailRow

functionservoy sDetail2100%height:30px2Methods DetailsgetClientIDname

getClientID()

dessIndent
Gets the id of the client.

This client id can be used to find the client from the headless client plugin.
Note that this client id is not the same id as the id displayed on the Aplicationb Server admin page.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRowgetDataProviderValuename

getDataProviderValue(contextName, dataprovider)

dessIndent
Get a data-provider value.
prs

Parameters

sIndentcontextNameThe context of the given method, null if it is global method or a form name for a form method

{String} dataprovider - Table Row (tr)idthe data-provider name as seen in Servoyret

Table Cell (td)class

Returns

DivObject - sIndentid the value for the data-provider.clients

Table Row (tr)

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetDataProviderValue-String_String_String
Table Row (tr)
idname
Table Cell (td)

getDataProviderValue

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Object
Span
stylefont-weight: bold;
getDataProviderValue
Span

Sample

Div
classsIndent
Code Block
languagejavascript
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);
	}
}
sIdentjavascriptlastDetailRowgetDataProviderValuename

getDataProviderValue(contextName, dataprovider, methodName)

tr

idclassdes Table Cell (td) DivsIndent
Get a data-provider value.
tr
idprs

Table Cell (td)class

Parameters

DivsIndent{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 - Table Row (tr)idif 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.tdretclass

Returns

DivObject - sIndentid the value of the data-provider.clients

Table Row (tr)

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idisValid
Table Row (tr)
idname
Table Cell (td)

isValid

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
isValid
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
returns true if this client is still valid/usable.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
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);
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idqueueMethod-String_String_ObjectArray_Function
Table Row (tr)
idname
Table Cell (td)

queueMethod

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
queueMethod
Span

Sample

Div
classsIndent
Code Block
languagejavascript
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);
	}
}
idsIdentjavascriptlastDetailRowisValidname

isValid()

dessIndent
returns true if this client is still valid/usable.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
queueMethodname

queueMethod(contextName, methodName, args)

dessIndent
Queues a method call on the remote server, without a callback method.
Please note that calling queueMethod without a callback does not return anything: no result of the remote method or no exception if something went wrong.
prs

Parameters

sIndentcontextNameThe context of the given method, null if it is global method or a form name for a form method.methodNameThe method name.argsThe arguments that should be passed to the method.
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
queueMethodname

queueMethod(contextName, methodName, args, notifyCallBackMethod)

Table Row (tr) Divclassdes Table Cell (td)sIndent
Queues a method call on the remote server. The callback method will be called when the method is executed on the server


and the return value is given as the JSEvent.data object with the JSEvent.getType() value of JSClient.CALLBACK_EVENT.


If an exception is thrown somewhere then the callback method will be called with


the exception as the JSEvent data object with the JSEvent.getType() value of JSClient.CALLBACK_EXCEPTION_EVENT

id

The second argument that is give back is the JSClient instance that did the call.
Table Row (tr)tdprsclass

Parameters

DivsIndent{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 -
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
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);
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetDataProviderValue-String_String_Object
Table Row (tr)
idname
Table Cell (td)

setDataProviderValue

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Object
Span
stylefont-weight: bold;
setDataProviderValue
SpanThe callback method that is called when the execution is finished.idclients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
setDataProviderValuename

setDataProviderValue(contextName, dataprovider, value)

Table Row (tr) Divclassdes Table Cell (td)idsIndent
Set a data-provider value.
Table Row (tr)tdprs

Parameters

div

classsIndent{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 - Table Row (tr)idthe value to set.ret

Table Cell (td)

Returns

Divclass

sIndentObject - the old value or null if no change.clients

Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
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);
	}
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetDataProviderValue-String_String_Object_String
Table Row (tr)
idname
Table Cell (td)

setDataProviderValue

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Object
Span
stylefont-weight: bold;
setDataProviderValue
Span

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
setDataProviderValuename

setDataProviderValue(contextName, dataprovider, value, methodName)

Table Row (tr)id Divclass

des Table Cell (td)idsIndent
Set a data-provider value.
Table Row (tr)prs

Table Cell (td)

Parameters

div

classsIndent{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 - Table Row (tr)idif 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.ret

Table Cell (td)class

Returns

DivsIndentObject - id the old value or null if no changeclients

Table Row (tr)

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idshutdown
Table Row (tr)
idname
Table Cell (td)

shutdown

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
shutdown
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
closes the client.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
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);
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idshutdown-Boolean
Table Row (tr)
idname
Table Cell (td)

shutdown

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
shutdown
Span
(force)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
closes the client.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Boolean} force
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
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);
}
Table Row (tr)
classlastDetailRow
Table Cell (td) 

Sample

Div
classsIndent
Code Block
languagejavascript
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);
	}
}
sIdentjavascriptlastDetailRowshutdownname

shutdown()

dessIndent
closes the client.
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
shutdownname

shutdown(force)

dessIndent
closes the client.
prs

Parameters

sIndentforce ;
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow