mxui.wm.UserInterface
The mxui.wm.UserInterface
subsystem provides an API to control the UserInterface.
Methods
isRtl()
This method is called to check whether the client is in RTL (right to left) or LTR (left to right) mode.
Returns
Type | Description |
---|---|
Boolean | true if the client is in RTL mode. |
newContext(widget)
This method is called to create a new context, bound to a widget.
Parameters
Name | Type | Description |
---|---|---|
widget | Widget | Optional widget to bind the context to. |
Returns
Type | Description |
---|---|
MxContext | A newly created MxContext. |
getContext(id, widget)
This method is called to get an existing context, or create a new context, bound to a widget.
Parameters
Name | Type | Description |
---|---|---|
id | Number | Id of the context to get. |
widget | Widget | Optional widget to bind the context to. |
Returns
Type | Description |
---|---|
MxContext | The MxContext. |
destroyContext(context)
This method is called to remove a context.
Parameters
Name | Type | Description |
---|---|---|
context | MxContext | Context to destroy. |
cleanContext(id, widget)
This method is called to remove the given widget from the context its listeners. If there are no listeners left, the context will be removed.
Parameters
Name | Type | Description |
---|---|---|
id | Number | Id of the context to get. |
widget | Widget | Widget to remove from given context. |
cleanWidgetContext(widget)
This method is called to remove the widget from all contexts. If there are no listeners left for a context, it will be removed.
Parameters
Name | Type | Description |
---|---|---|
widget | Widget | Widget to remove from all contexts. |
downloadFile(args)
This method is called to download a file or FileDocument.
Parameters
Only one of the mxobject / url parameters should be set.
Name | Type | Description |
---|---|---|
args.mxobject | MxObject | The FileDocument to download. |
args.url | String | The url of the file to download. |
args.target | String | What to do with the download. “internal” shows a download dialog, while “window” opens the file in another window in the browser. |
args.error | Function | A function to handle errors (like “file not foud”). |
info(message, args)
This method is called to show an info message to the user.
Parameters
Name | Type | Description |
---|---|---|
message | String | The message to show to the user. |
args.modal | Boolean | Whether the message should be shown blocking, or as a toaster. |
warn(message, args)
This method is called to show a warn message to the user.
Parameters
Name | Type | Description |
---|---|---|
message | String | The message to show to the user. |
args.modal | Boolean | Whether the message should be shown blocking, or as a toaster. |
error(message, args)
This method is called to show an error message to the user.
Parameters
Name | Type | Description |
---|---|---|
message | String | The message to show to the user. |
args.modal | Boolean | Whether the message should be shown blocking, or as a toaster. |
exception(message)
This method is called to show a blocking exception message to the user.
Parameters
Name | Type | Description |
---|---|---|
message | String | The message to show to the user. |
validations(validations)
This method is called to show validation feedback from the Runtime to the user in a blocking popup.
Parameters
Name | Type | Description |
---|---|---|
validations | Array | mendix.lib.ov validation messages. |
confirm(params)
Show a dialog asking the user for confirmation. The dialog has two buttons: one for proceeding and one for cancellation.
This function does not perform any translations.
Parameters
Name | Type | Description |
---|---|---|
message | String | The confirmation message. |
proceedtext | String | The text that should be shown on the proceed button. |
canceltext | String | The text that should be shown on the cancel button. |
callback | Function | Function to handle the result of the dialog. It should take a single parameter, proceed , indicating the choice of the user. It should not use this . |
Example
Showing a confirmation message:
mx.ui.confirm({
message : "Do you want to feed your dog?",
proceedtext : "Yes, where is her food?",
canceltext : "No, I'll feed her later!",
callback : function(proceed) {
if (proceed) {
alert("Feeding!");
} else {
alert("Not feeding!");
}
}
});
action(name, params, scope)
Execute a Microflow, optionally with some UI interaction.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the Microflow to execute. (required) |
params.params.applyto | String | What to apply the Microflow to. Can be one of “none”, “set”, “selection” or “selectionset”. “none” is the default. |
params.params.guids1 | Array | The GUIDs to apply the Microflow to. |
params.params.xpath1 | String | The root entity for the XPath query. |
params.params.constraints | String | The constraints for the XPath query. |
params.params.sort2 | Array | Sorting of XPath query results before feeding them to the Microflow. |
params.params.gridid | String | The grid ID of the data grid which is providing the selection information. |
params.context1 | MxContext | The context for the Microflow. |
params.progress | Object | If set, show a progress indicator while running the Microflow. |
params.progress.type | String | The type of progress indicator, either “popup” or “modal”. |
params.progress.message | String | The message shown in the progress indicator. |
params.caller | Scriptable | The caller instance, on which server instructions can be executed. |
params.async | Boolean | Whether the Microflow should be executed asynchronously. Defaults to false . |
params.callback | Function | Function to handle the result when successful. It should take a single parameter, response . response contains the result of the Microflow. |
params.error | Function | Function to handle errors. It should take a single parameter, error , which is set to undefined when the server cannot be accessed, or an Object describing the error. |
scope | Object | The scope in which to execute the callback and error callbacks. |
1 One of either the guids
or xpath
parameters is required.
2 Required when using an XPath query to specify Microflow parameters.
Microflow parameters
The applyto
parameter indicates which objects are passed to the Microflow as input.
Name | Description |
---|---|
none | Don’t pass any objects to the Microflow. |
selection | Pass the objects with the given GUIDs. |
set | Pass the objects matching the given XPath query. |
selectionset | Pass the objects matching the given XPath query. If gridid is set, and the corresponding grid is single selection, only the first queried object is considered. |
Examples
Calling a simple Microflow, not expecting any selected entity and without a progress indicator:
mx.ui.action("MyFirstModule.PetCat", {
callback : function(response) {
// no MxObject expected
alert("Just petted the cat a little");
},
error : function(error) {
alert(error.description);
}
});
Show a progress indicator while calling a Microflow expecting a selected entity:
mx.ui.action("MyFirstModule.GetFavoriteFood", {
progress : {
type : "modal",
message : "Retrieving cat's favorite food..."
},
params : {
applyto : "set",
xpath : "//MyFirstModule.Cat",
constraints : "[id=281530811285515]"
},
callback : function(response) {
// expect single MxObject
alert(response.get("manufacturer"));
},
error : function(error) {
alert(error.description);
}
}, this);
registerTarget(name, target)
This method is called to register a target on which actions can be executed via executeAction.
Parameters
Name | Type | Description |
---|---|---|
name | String | Name of the target, which should be passed to executeAction. |
target | Function | Function to execute actions to this target. |
getTargetScope(name)
This method is called to get a executeAction target by name.
Parameters
Name | Type | Description |
---|---|---|
name | String | Name of the target. |
Returns
Type | Description |
---|---|
Function | The function associated with given target name. |
getLocale()
This method is called to get the current locale.
Returns
Type | Description |
---|---|
String | The current locale (eg. en_US). |
getProgressIndicator(type, message)
This method is called to create a progress indicator.
Parameters
Name | Type | Description |
---|---|---|
type | String | Type of progress bar (“popup” or “modal”). |
message | String | Message to show in the progress bar. |
Returns
Type | Description |
---|---|
Object | The progress indicator, which implements a “start”, “stop”, and “error” method. |
hasTranslation(key)
This method is called to chech whether translations are available for given key.
Parameters
Name | Type | Description |
---|---|---|
key | String | The key to find in the translation map. Normally this would be the declaredClass. |
Returns
Type | Description |
---|---|
Boolean | Whether translations are available for given key. |
translate(key, text)
This method is called to translate a system text into the current locale.
Parameters
Name | Type | Description |
---|---|---|
key | String | The key to find in the translation map. Normally this would be the declaredClass. |
text | String | The name of the system text to translate. |
Returns
Type | Description |
---|---|
String | The translation of the given system text in the current locale. |
startup(callback)
This method is called to startup the subsystem.
Parameters
Name | Type | Description |
---|---|---|
callback | Function | The function to be called when startup is finished. |
shutdown()
This method is called to shutdown the subsystem.
isLoaded()
This method is called to check whether the subsystem has been started.
Returns
Type | Description |
---|---|
Boolean | true if the subsystem has been started. |