mx.ui
Basic UI functionality.
Methods
action(name, params, scope)
Execute a Microflow from the UI. This is basically a wrapper around mx.data.action()
, setting the default caller
to the current form, and giving the option of showing a progress bar while running the Microflow.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the Microflow to execute. (required) |
params.progress | String | If set, a progress indicator is shown while running the Microflow. When set to “modal” the indicator is modal, otherwise it is not. |
params.progressMsg | String | Message to show while Microflow is running when params.progress is set. |
scope | Object | The scope in which to execute the callback and error callbacks. |
See also mx.data.action()
, for the other accepted parameters.
Example
mx.ui.action("MyFirstModule.StartEngine", {
context: new mendix.lib.MxContext(),
progress: "modal",
callback: function(result) {
console.log("Engine started: " + result);
}
});
back()
This method is called to go one step back in history, closing the current in content Form.
Example
mx.ui.back();
showLogin(args)
Show the login screen if it is not already shown.
Parameters
Name | Type | Description |
---|---|---|
args.no_alert | Number | Do not show a session expired message, only HTTP errors. |
args.http_code | Number | HTTP code triggering the login. |
Example
mx.ui.showLogin({
http_code: 401 // show login screen with an indication that the session has expired.
});
hideLogin()
Hide the login screen if it is shown.
Example
mx.ui.showLogin(); // show login screen
mx.ui.hideLogin(); // hide it again
showProgress()
This method is called to show the loading dialog.
Returns
A progress id that can be used to close the dialog again.
Example
var pid = mx.ui.showProgress(); // show progress dialog
mx.ui.hideProgress(pid); // hide it again
hideProgress(id)
This method is called to hide the loading dialog.
Example
var pid = mx.ui.showProgress(); // show progress dialog
mx.ui.hideProgress(pid); // hide it again
openForm(path, args, scope)
This method is called to open a form, either in content, in a DOM node or in a (modal) popup.
Parameters
Name | Type | Description |
---|---|---|
path | String | The path to the form. |
args.location | String | The location to open the form, either “content”, “popup” or “modal”. |
args.domNode | DOMNode | The domNode to open the form in. |
args.title | String | Title of the form. If omitted, the title from the form template is used. |
args.context | MxContext | Context passed to the form. |
args.instance | Form | Previously retrieved form to use instead of retrieving it through path . |
args.params | Object | Optional params for the form. |
args.callback | Function | The function to be called when ready. |
args.error | Function | The function to be called when an error occurs. |
scope | Object | Scope in which the error and callback handler are invoked. |
Example
mx.ui.openForm("MyFirstModule/Puppies.mxf", {
location: "popup",
callback: function(form) {
console.log(form.id);
}
});
getForm(path, args, scope)
This method is called to get a form instance.
Parameters
Name | Type | Description |
---|---|---|
path | String | The path to the form. |
args.params | Object | Parameters passed to the constructor of the form. |
args.error | Function | The function to be called when an error occurs. |
args.callback | Function | The function to be called with the form instance as parameter. |
scope | Object | Scope in which the error and callback handler are invoked. |
Example
mx.ui.getForm("MyFirstModule/Puppies.mxf", {
params: { place: "content" },
callback: function(form) {
console.log("Retrieved a form with title " + form.title);
}
});
getTemplate(id, name)
This method is called to get a template for a specific widget.
Parameters
Name | Type | Description |
---|---|---|
id | String | The widget id. |
name | String | The name of the template. |
Returns
Type | Description |
---|---|
DocumentFragment | Widget template node. |
Example
mx.ui.getTemplate("12", "content"); // Returns template 'content' for widget with mxid '12'.
info(msg, modal)
This method is called to show an info message.
Parameters
Name | Type | Description |
---|---|---|
msg | String | The message to show. |
modal | Boolean | Whether the dialog will be modal or not. |
Example
mx.ui.info("Let me inform you about something."); // shows a non-modal message
warning(msg)
This method is called to show a warning message.
Parameters
Name | Type | Description |
---|---|---|
msg | String | The message to show. |
modal | Boolean | Whether the dialog will be modal or not. |
mx.ui.warning("Let me warn you about something.", true); // shows a modal warning
error(msg)
This method is called to show an error message.
Parameters
Name | Type | Description |
---|---|---|
msg | String | The message to show. |
modal | Boolean | Whether the dialog will be modal or not. |
Parameters
mx.ui.error("Something went wrong."); // shows a non-modal error
exception(msg)
Show a message for a fatal error in a modal dialog.
Parameters
Name | Type | Description |
---|---|---|
msg | String | The message to show. |
Parameters
mx.ui.error("Something went very wrong."); // shows a modal fatal error
confirmation(args)
Show a confirmation dialog before calling a given function.
Parameters
Name | Type | Description |
---|---|---|
cancel | String | Caption for the cancel button. |
proceed | String | Caption for the proceed button. |
content | String | Message to show in the dialog. |
handler | Function | Function to call when the proceed button is clicked. |
Example
mx.ui.confirmation({
content: "Do you really want to eat a burger?",
proceed: "I really do",
cancel: "I'll pass",
handler: function() {
console.log("eating burger");
}
});