JSClient
Overview
The JSClient serves as a wrapper for a headless client, providing tools to interact with the headless client plugin. Constants like CALLBACK_EVENT and CALLBACK_EXCEPTION_EVENT help identify whether callback execution was successful or if an exception occurred.
The client enables several functionalities, such as retrieving its unique client ID, which can be used for identifying or managing the client. It supports accessing or modifying data provider values based on a specified context or active method call, ensuring precise value management.
The client allows for queuing method calls on the remote server, with / without a callbacks.Validation checks ensure that the client is still active and usable, while methods are available to gracefully or forcefully shut down the client as required.
Constants Summarized
Constant that is returned as a JSEvent type when in the callback method when it executed normally.
Constant that is returned as a JSEvent type when in the callback method when an exception occurred.
Methods Summarized
void
Queues a method call on the remote server, without a callback method.
void
Queues a method call on the remote server.
Constants Detailed
CALLBACK_EVENT
Constant that is returned as a JSEvent type when in the callback method when it executed normally.
Type String
Sample
CALLBACK_EXCEPTION_EVENT
Constant that is returned as a JSEvent type when in the callback method when an exception occurred.
Type String
Sample
Methods Detailed
getClientID()
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.
Returns: String The unique identifier of the client, which can be used to locate the client via the headless client plugin.
Sample
getDataProviderValue(contextName, dataprovider)
Get a data-provider value.
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
Returns: Object the value for the data-provider.
Sample
getDataProviderValue(contextName, dataprovider, methodName)
Get a data-provider value.
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.
Returns: Object the value of the data-provider.
Sample
isValid()
returns true if this client is still valid/usable.
Returns: Boolean True if the client is still valid and usable; false otherwise.
Sample
queueMethod(contextName, methodName, args)
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.
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.
Array args The arguments that should be passed to the method.
Returns: void
Sample
queueMethod(contextName, methodName, args, notifyCallBackMethod)
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.
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.
Array 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
setDataProviderValue(contextName, dataprovider, value)
Set a data-provider value.
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.
Returns: Object the old value or null if no change.
Sample
setDataProviderValue(contextName, dataprovider, value, methodName)
Set a data-provider value.
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.
Returns: Object the old value or null if no change
Sample
shutdown()
closes the client.
Returns: void
Sample
shutdown(force)
closes the client.
Parameters
Boolean force ;
Returns: void
Sample
Last updated
Was this helpful?