On Click Event and Events Section
Introduction
Events specify actions which can be triggered when the end-user interacts with a widget. This interaction can occur in a number of ways:
- On click – this is the most common interaction and can be used with many widgets
- On change – for input elements
- On enter – for input elements
- On leave – for input elements
Triggering Actions
On Click
An On click event specifies an event that is executed when a user clicks a widget. Often the On click property is a part of the Events section in properties. For example, you can specify that when a user clicks a customer’s profile image, the page with this customer’s details will open:
An on-click event is common for many widgets (for example, image, buttons, list view).
The On click property specifies what action is executed when a user click a widget.
Disabled During Action
This property is only shown when Call a microflow or Call a nanoflow is selected as the on-click event. Selecting Disabled during action disables the button until the action is completed or failed.
On Change
The on-change property specifies an action that will be executed when leaving the widget, either by using the Tab key or by clicking another widget, after the value has been changed.
On Enter
The on-enter property specifies an action that will be executed when the widget is entered, either by using the Tab key or by clicking it with the mouse.
On Leave
The on-leave property specifies an action that will be executed when leaving the widget, either by using the Tab key or by clicking another widget.
This differs from the On change property in that the event will always be triggered, even if the value has not been changed.
Event Actions
When an event is triggered, you can choose what action is triggered. Possible options are the following ones:
- Do nothing (default)
- Show a page
- Call a microflow
- Call a nanoflow
- Open link
- Create object
- Save changes
- Cancel changes
- Close page
- Delete object(s)
- Synchronize
- Sign out
- Call workflow
- Show user task page
- Show workflow admin page
- Complete user task
Do Nothing
No action is taken. This option is useful for setting up a page without defining the underlying functionality yet.
Show a Page
The Show a page event opens the specified page. Select the page which opens using the options below:
-
Page – a page that should open.
-
Page settings – opens a dialog box enabling you to configure the page in more detail (including the page title).
-
Page for specializations – allows you to configure a different page for each specialization of the context object. If this action is placed inside a data view, it is possible to configure different page (or pages) for each specialization of the data view object. If this action is placed in a data grid, it is possible to configure different pages for each specialization of the data grid entity. This setting is not shown when there is not a context object or when the context object has no specializations.
Page Settings
Page settings opens a dialog box enabling you to configure the page in more detail:
-
Page – a page that should open.
-
Page title – the page you open can be given a unique title, depending on where you open it from. This allows you to re-use the same page for different purposes. For example, by setting the title to New Customer from one button and Edit Customer from another, you can use the same page for editing new and existing customers.
This option is activated by checking the Override page title checkbox.
-
Page arguments – a list of parameters of the selected page and the objects that will be passed to each of them.
Page Arguments
Page arguments are automatically configured based on the parameters of the selected page and the available arguments. In general, arguments are taken from any enclosing data widget. If the data widget enclosing the widget calling a page is inside another (nested) data widget, then objects from that data widget and any others in which it is nested can also be passed.
Call a Microflow
The Call a microflow event executes the specified microflow.
The following settings are specific for this event:
Microflow
The microflow that should be executed.
You can either select an existing microflow or create a new microflow by clicking the New button from the Select Microflow dialog box.
In Studio Pro 10.4.0 and above, when creating a new microflow, a dialog box is shown where you can set the name and select parameters for the new microflow. You can choose the data view, snippet, page parameter, or available selection from which the parameter must be created in the new microflow:
If there is nothing to pass to the new microflow, then a dialog box is shown where you can only specify the name of the microflow:
Microflow Settings
Microflow settings opens a dialog box enabling you to specify what parameters will be passed to the microflow and how the microflow will be run.
Microflow
This duplicates the Microflow specified above.
Microflow Arguments
Microflow arguments are automatically configured based on the parameters of the selected microflow and the available arguments. In general arguments are taken from any enclosing data widget. If the data widget enclosing the widget calling a microflow is inside another (nested) data widget, then objects from that data widget and any others in which it is nested can also be passed.
If the microflow is triggered within a grid and has an object list parameter, the objects which are passed in the list depend on the selection mode of the grid. Simple multi-selection allows for either all rows or selection, and defaults to selection. This can be configured via the drop-down menu in the microflow settings page. A grid with single selection always passes all rows to the microflow.
Microflow Call Type
Microflow call type specifies whether the microflow is executed synchronously or asynchronously.
-
Synchronous (default) – The client waits until the microflow is done executing
-
Asynchronous
- The client executes the microflow but does not wait for the result
- The client checks the server every ten seconds to see whether the microflow is done executing
- Only set the call type to asynchronous if you experience problems — sometimes, if a request takes too long to handle, the request will be sent again by an (impatient) proxy server
Show Progress Bar
Show progress bar specifies whether a progress bar is shown during the execution of the microflow. The message shown in the progress bar can be set with the ‘Progress message’ property.
Value | Description |
---|---|
None | No progress bar is shown. |
Non-Blocking | A progress bar is shown, but the end-user can continue working. |
Blocking | A progress bar is shown and the end-user must wait until the microflow is done. |
Progress Message
If a progress bar is shown, Progress message is the text which is shown next to the progress bar.
Ask Confirmation
If Ask Confirmation is set to Yes, the end-user will be asked for confirmation before proceeding with the microflow. This is useful in cases where an operation modifies or deletes a lot of data or when it takes a lot of time to complete.
The user will be prompted with the text set in Question, below. The window title of the confirmation pop-up is determined by a system text (category ‘Message dialog title’).
The default value is No.
Question
If Ask confirmation is set to yes, Question is what is shown to the user. Ensure that the question asked is clear and that the captions set on the buttons are unambiguous.
For example, Are you sure you want to empty the trash can?
Proceed Button Caption
If Ask confirmation is set to yes, this is the caption for the button that proceeds with the execution of the microflow.
For example, Empty it.
Cancel Button Caption
If Ask confirmation is set to yes, this is the caption for the button that cancels the execution of the microflow.
For example, Do not empty.
Maintain Selection After Microflow
For buttons which call a microflow from inside a grid, Maintain selection after microflow specifies whether the current selection of rows in the grid should be maintained after executing the microflow.
Abort on Validation Errors
For microflows that are used within a data widget, setting Abort on Validation Errors to Yes forces widget validations to be performed before executing the microflow. If the validations fail, the microflow will not be executed.
Value | Description |
---|---|
Yes (default) | This will prevent the microflow from executing if there are any validation errors on the page. |
Only for this widget | This will prevent the microflow from executing if there are validation errors in the current widget. |
No | The microflow will always be executed. |
Call a Nanoflow
The Call a nanoflow event executes the specified nanoflow.
Nanoflow
Set the Nanoflow property to specify a nanoflow that should be executed.
You can either select an existing nanoflow or create a new nanoflow by clicking the New button from the Select Nanoflow dialog box.
In Studio Pro 10.4.0 and above, when creating a new nanoflow, a dialog box is shown where you can set the name and select parameters for the new nanoflow. You can choose the data view, snippet, page parameter, or available selection from which the parameter must be created in the new nanoflow.
If there is nothing to pass to the new nanoflow, then a dialog box is shown where you can only specify the name of the nanoflow.
Open Link
The Open link event triggers an action based on a link type, some of which are specific to mobile devices. The following properties are specific for this event:
- Link Type – the type of action triggered when pressing the button. For information on available link types, see the Link Types section below.
- Address – usage of the address property depends on the chosen link type and whether you want to use a literal or to use the value of an attribute.
- Use literal value – allows you to enter a fixed address.
- Use attribute – allows you to select an attribute which contains the value to be used as the address. In this case, the widget must have an entity as its context (for example, it is inside a data view).
Link Types
The table below described link types available for the Open link on click event:
Value | Description | Example |
---|---|---|
Web (default) | Navigate to a website URL | https://mysubdomain.mydomain.tld/mypage |
Specifies an email address to which to send an email | firstname.secondname@mailprovider.tld |
|
Call | Starts a phone call to this number | +1-202-555-0165 |
Text | Specifies a number to which to send a text message | +1-202-555-0112 |
Create Object
The Create object event creates a new object. The following properties are specific for this event:
- Entity (path) – specifies which entity to create. It is also possible to choose an association (if available) from the context object. If an entity is configured, a new instance of the entity will be created. If an entity through association from the context object is configured, a new instance of the entity will be created and an object associated with the context will be created.
- On {event} page – specifies which page should be shown to allow the end-user to enter values for the new created object. This page must accept a context parameter object (for example, a data view) with the same entity or a sub-type of the created entity. {event} specifies which event is being used to trigger this action (click, for example).
- Page settings - opens a dialog box enabling you to configure the page in more detail. See the Page Settings section in Show a page for more information.
Save Changes
The Save changes event commits all changes made to the objects in Editable widgets on the page. If a non-editable widget displays an object and it is modified by, for example, a microflow, the object is not committed. For information on editability, see the Editability section in Properties Common in the Page Editor.
The following properties are specific for this event:
- Close page – specifies whether the current page should be closed.
- Auto-synchronize – specifies whether synchronization should happen when the save button is clicked for a Mendix application running in an offline profile. When an object is saved in a Mendix application running in an offline profile it is stored in a local database until it can be synchronized with the server (for more information on the capabilities of offline apps, see Offline First. In practice, this means that uploading a new object to the server requires two distinct actions: saving the object and synchronizing it.
This event cannot be used on pages that change external entities. Use the Send External Object activity to save changes to external entities.
Cancel Changes
The Cancel changes event rolls back all changes made on the page.
Set the Close page property to indicate whether the current page should be closed.
Close Page
The Close page event closes a pop-up window (for pop-up pages) or navigates to the previously visited page (for content pages).
Delete object(s)
When placed in the control bar of a data grid, template grid, or reference set selector the Delete object(s) event will delete the selected objects.
In other situations, the user can select which objects to delete. The object can be from any surrounding data container, snippet parameter, page parameter or selections of pluggable widgets (for example a Data Grid 2 or Gallery widget).
This event cannot be used to delete external objects. Use a microflow with a Delete External Object activity to delete external objects.
Set the Close page property to indicate whether the current page should be closed.
Synchronize
The Synchronize event synchronizes the data stored locally on your device with the server database.
Sign Out
The Sign out event signs the currently signed-in user out. When no user is signed in, no action is performed.
Call Workflow
The Call workflow event triggers the specified workflow.
An element calling this event should be placed in a data container connected to the WorkflowContext entity.
The following properties are specific for this event:
- Workflow – A workflow that should be executed.
- Close page – Specifies whether the current page should be closed.
- Commit – Specifies whether the data container object should be committed when running a workflow.
Show Workflow Admin Page
Show workflow admin page opens a workflow overview page. This page is typically used by a workflow administrator role to inspect status of a workflow instance and to manage the instance, for example, abort a workflow if required.
An element calling this event should be placed in a data container connected to the System.Workflow entity. For more information, see the Instance-Related Entities section in Workflow Engine.
Show User Task Page
Show user task page opens an overview page set for the user task in properties. An element calling this event should be placed in a data container connected to the System.WorkflowUserTask entity.
The following properties are specific for this event:
-
Auto-assign – Assigns the user task automatically to the user who has opened the task page if the user task has not been assigned to anyone yet. This option is enabled by default.
Only the user who is assigned to the task can complete it (otherwise, it results in a Runtime error). If you choose to not automatically assign the user to the task when the page is opened, make sure that the user is assigned before the task is completed. For example, you can add the Assign to me button to the page. -
Who can open – Specifies who is able to open the user task page when a user has already been assigned to it.
- Assigned user (default) – Only the user who is currently assigned to the task is able to open the user task page.
- Users with access – All users who have access to the user task can open the user task page. This option means that multiple users can open the page at the same time. Only the assigned user is able to complete the task, however, other users can make changes to the page, and the data will not be saved unless you add a Save button. This button saves data, but does not complete the task. Take into account that when two users have the task page open simultaneously, data from the user who saves changes the last is stored and this will overwrite data from the other user.
For more information, see the Instance-Related Entities section in Workflow Engine.
Complete User Task
The Complete user task event marks the specified user task in the workflow as completed.
An element calling this event should be placed in a data container connected to the System.WorkflowUserTask entity.
The following properties are specific for this event:
- User task – The user task that should be marked as completed.
- Outcome – Lists the outcomes of the selected user task and follows the selected outcome. If the user task has only one outcome, the Default is set as an outcome and the property cannot be edited.
- Close page – Specifies whether the current page should be closed.
- Commit – Specifies whether the data container object should be committed when marking the task as completed.