mx
mx
is the client core. It contains the subsystems and some configuration parameters.
Properties
appUrl
This is the root URL of the application, which defaults to the URL of the document, excluding the hash (‘#’) part.
baseUrl
This is the URL of the XAS instance, relative to the application URL, which defaults to mx.appUrl + "xas/"
.
modulePath
This is the url of the modules (custom widgets), relative to the dojo dir, which defaults to "../../widgets/"
.
Methods
addOnLoad(callback)
This method is called to add a function to be called when the client is finished loading. If the client is already loaded, the function will be called immediately.
Parameters
Name | Type | Description |
---|---|---|
callback | Function | The function to be called when the client is finished loading. |
Example
mx.addOnLoad(function() {
console.log("You can use client functionality now");
});
login(args)
This method is called to authorize the current user. If there is no session yet, or the session has expired, the runtime is probed for a guest account. If anonymous users are not allowed, the login screen is displayed. When authorized the client is loaded.
Parameters
Name | Type | Parameters |
---|---|---|
args | Object | Parameters passed to mx.ui.showLogin() when the login screen should be displayed. |
Example
mx.login({ no_alert: true }); // Tries to login, and shows login dialog when unsuccesful.
logout()
This method is called close to restart the client when the user logs out.
Example
mx.logout(); // Restarts the client.
onError(error)
When an error is not handled in the client, the error is passed to onError
. Other code can detect these errors by attaching to onError
. E.g. the UI code connects to it to show the error to the user.
When client code does not handle an error situation itself, it can pass the error to onError
for further handling.
Parameters
Name | Type | Description |
---|---|---|
error | Error | The error object describing what went wrong. |
Examples
dojo.connect(mx, "onError", null, function(error) {
console.log(error.message);
});
mx.server.request({
request: {
action: "rollback",
params: {
guid: "123456"
},
options: {
callback: function(state, response) {
console.log("rollback successful");
},
error: function(e) {
// Detect the error but rely on onError() to handle the error further.
mx.onError(e);
}
}
});