Container of the Mendix client subsystems.
Namespaces
Members
(static) appUrl :string
Root URL of the application, e.g. https://domain.com/mendixapp/
.
Type:
- string
(static) baseUrl :string
URL of the XAS instance, e.g. https://fomain.com/mendixapp/xas/
.
Type:
- string
(static) modulePath :string
The URL of the modules (custom widgets), relative to the dojo directory.
Type:
- string
(static) version :string
Version of the Mendix platform
Type:
- string
Methods
(static) addOnLoad(callback)
Adds 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 |
mx~AddOnLoadCallback | function to be called when the client is finished loading |
Example
mx.addOnLoad(function() {
console.log("You can use client functionality now");
});
(static) login(username, password, onSuccess, onError)
Tries to login using a username and password.
Parameters:
Name | Type | Description |
---|---|---|
username |
string | username to login with |
password |
string | password to login with |
onSuccess |
mx~LoginSuccessCallback | called when the login is successful |
onError |
mx~LoginErrorCallback | called when the login is successful |
Example
mx.login("fred", "fred's unguessable password", function() {
console.log("success");
}, function() {
console.log("failure");
});
(static) logout()
Logs out the user and restarts the client.
Example
mx.logout(); // Restarts the client.
Type Definitions
AddOnLoadCallback()
Callback that can be registered with mx.login
LoginErrorCallback()
Error callback of mx.login
LoginSuccessCallback()
Success callback of mx.login
Events
onError
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. |
Example
aspect.after(mx, "onError", function(error) {
console.log(error.message);
}, true);
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);
}
}
}
});