JavaScript Client-side API Reference
improve this page | report issueOverview
Click to view the API reference for JavaScript applications.
Click to view the Objective-C API reference for JavaScript applications.
The following table lists the functions that you can perform in Javascript applications, and the corresponding API method.
Function | Description |
---|---|
WL.Client , WL.App |
Initializing and reloading an application, Globalizing application texts |
WLAuthorizationManager |
Obtain client ID and authorization header |
WL.Logger |
Printing log messages to the log for the environment |
WL.NativePage |
Switching the currently displayed, web-based screen with a natively written page |
WLResourceRequest |
Send requests to protected and unprotected resources |
WL.JSONStore |
Client-side API providing a lightweight, document-oriented storage system |
Additional information
The Options object
The options
object contains properties that are common to all methods. It is used in all asynchronous calls to MobileFirst Server.
Sometimes it is augmented by properties that are only applicable to specific methods. These additional properties are detailed as part of the description of the specific methods.
The common properties of the options object are as follows:
options = {
onSuccess: successHandler(response),
onFailure: failureHandlder(response),
invocationContext: invocation-context
};
The meaning of each property is as follows:
Property | Description |
---|---|
onSuccess |
Optional. The function to be invoked on successful completion of the asynchronous call. The syntax of the onSuccess function is: success-handler-function(response) where response is an object that contains at a minimum the following property:
response object contains additional properties, these properties are detailed as part of the description of the specific method. |
onFailure |
Optional. The function to be invoked when the asynchronous call fails. Such failures include both server-side errors, and client-side errors that occurred during asynchronous calls, such as server connection failure or timed out calls. Note: The function is not called for client-side errors that stop the execution by throwing an exception. The syntax of the onFailure function is: failure-handler-function(response) where response is an object that contains the following properties:
response object contains additional properties, these properties are detailed as part of the description of the specific method. |
invocationContext |
Optional. An object that is returned to the success and failure handlers. The invocationContext object is used to preserve the context of the calling asynchronous service upon returning from the service. For example, the invokeProcedure method might be called successively, using the same success handler. The success handler needs to be able to identify which call to invokeProcedure is being handled. One solution is to implement the invocationContext object as an integer, and increment its value by one for each call of invokeProcedure . When it invokes the success handler, the MobileFirst framework passes to it the invocationContext object of the options object associated with the invokeProcedure method. The value of the invocationContext object can be used to identify the call to invokeProcedure with which the results that are being handled are associated. |
The WL.ClientMessages object
You can see a list of the system messages that are stored in the WL.ClientMessages
object, and enable the translation of these system messages.
The WL.ClientMessages
object is an object that stores the system messages that are defined in the worklight/messages/messages.json file. This file is in the environment folder of the projects that you generated with Mobile Foundation. To enable the translation of a system message, you must override the value of this message in the WL.ClientMessages
object, as indicated in the following code example:
WL.ClientMessages.invalidUsernamePassword="The custom user name and password are not valid";
Note: You must override the system messages on a global JavaScript level because some parts of the code run only after the application successfully initialized.
JavaScript API Reference
Objective-C API reference (for Cordova)
▲Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.