Mendix uses visual models to define the logic of your application, we call those models Microflows. A Microflow is a visual way of expressing what traditionally would be written in code. This how-to explains how you can create a custom save button on a detail page by utilizing Microflows.
Before you start with this how-to please complete the following prerequisites:
- Create a basic domain model with this how-to
- Create overview and detail pages for the Customer object using this how-to
- Create a menu item to access the customer overview page using this how-to
2. Replacing the Default Save Button with a Custom one
- Open the customer detail page. It should look similar to this:
- Select the Save button and remove it by pressing the delete button.
- Right click the Cancel button and select Microflow from the Add button left menu.
- Double click the new Microflow button to open its properties:
- Change the caption to Save.
- Change the image to an image of your choice.
- Click Select… in the Events section to add a new microflow with the name _CustomerSave.
- Save the new Microflow button by clicking OK.
3. Re-creating the Default Save Behavior
Right click the new Microflow button and select Go to microflow to open the new Microflow
The Microflow should look like this:
Open the toolbox. It should be on the bottom right of the Mendix Modeler.
If you can’t find the toolbox, you can re-open it from the view menu.
Drag a Commit object(s) action from the toolbox to the line between the green start and red end event. This inserts a commit action activity.
Double click the new activity to open its properties.
Select Customer as input variable and click OK. The Microflow should now look like this:
Drag a Close page action from the toolbox to the line between the green start and red end event. This inserts a close page action activity.
You have now re-created the default save behavior. The Microflow should look like this:
4. Extending the Microflow with Your Own Functionality
- Drag a Show message action from the toolbox to the line between the start and end event. This inserts a show message action activity.
- Double click the new activity to open its properties:
- Select the type of message.
- Enter a message as Template value.
- Click OK to save the properties. The Microflow should now look like this:
5. Related content
- Defining access rules using XPath
- Triggering Logic using Microflows
- Creating a Custom Save Button
- Extending Your Application with Custom Java
Learn more using the following links: