Child pages
  • JSClient

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Div
styledisplay: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.

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
Constant 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.



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getClientID()
Gets the id of the client.
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)
getDataProviderValue(contextName, dataprovider)
Get a data-provider value.
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)
getDataProviderValue(contextName, dataprovider, methodName)
Get a data-provider value.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
isValid()
returns true if this client is still valid/usable.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
queueMethod(contextName, methodName, args, notifyCallBackMethod)
Queues a method call on the remote server.
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)
setDataProviderValue(contextName, dataprovider, value)
Set a data-provider value.
Table Row (tr)
Table Cell (td)
Object
Table Cell (td)
setDataProviderValue(contextName, dataprovider, value, methodName)
Set a data-provider value.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
shutdown()
closes the client.
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
shutdown(force)
closes the client.



HTML Table
idconstant
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Details
Table Body (tbody)
idCALLBACK_EVENT
Table Row (tr)
idname
Table Cell (td)

CALLBACK_EVENT

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant that is returned as a JSEvent type when in the callback method when it executed normally.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
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)
idCALLBACK_EXCEPTION_EVENT
Table Row (tr)
idname
Table Cell (td)

CALLBACK_EXCEPTION_EVENT

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant that is returned as a JSEvent type when in the callback method when an exception occurred.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
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)
 



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

Returns

Div
classsIndent
Object - the value for the data-provider.
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)
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
(contextName, dataprovider, methodName)
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 - 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.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Object - the value of the data-provider.
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)
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
(contextName, methodName, args, notifyCallBackMethod)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
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
The second argument that is give back is the JSClient instance that did the call.
Table Row (tr)
idprs
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} 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.
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
Span
(contextName, dataprovider, value)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Set a data-provider value.
Table Row (tr)
idprs
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.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Object - the old value or null if no change.
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
(contextName, dataprovider, value, methodName)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Set a data-provider value.
Table Row (tr)
idprs
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 - 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.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Object - the old value or null if no change
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)
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)