Mendix — Move to the Desktop Modeler!

Heshani Samarasekara
6 min readMar 14, 2018

--

This is my second blog post on Mendix and in this I will talk few more things about Mendix. If you are totally new to this and looking for an assistance, please refer my first post ‘Mendix — Create the Simplest App!’.

So in here what I’m going to focus on the Desktop Modeler, as it has more functionalities than Web Modeler. First install the Desktop Modeler which is compatible with your Web Modeler version. If you remember in my first post I mentioned that once we created an app, it asks from what we need to edit it. When we install the desktop modeler, we can select the option ‘Edit in Desktop Modeler’ from there. Or else, you can directly open the Desktop Modeler and then go to File →Open Project → Mendix Team Server to select a project you have already created on Mendix web. Or you can directly create new app from File → New Project.

Here I will tell you how to export an existing app in toDesktop Modeler. So after we open the project in our Desktop Modeler, we can see a little different interface than we saw in the web modeler. Don’t worry. You’ll get familiar 😉

Okay when you open your app, you have to sync the project with the web modeler. For that you have to go to Project →More Versioning →Sync with Web Modeler. After you do that it will take some time to fetch the changes.

Once you finished merging you have to confirm the changes and finish the sync.

You can do exactly same things we did with web modeler in here, and some more too. Try to add some new pages, microflows to our app, and get familiar. With the Desktop Modeler, we’ll add some more functionalities to our app. And we will get familiar with Java Actions.

First we’ll add some validation rules to our form details. With current format anyone can add anything for age or telephone number. We’ll validate the two first.

To validate the input, go to Domain Model and double click on the Employee entity.

Here in attribute tab, we can set limits to each attribute. Just select the attribute and click Edit. In there we can set a limit for the strings if we want. I limit the mobile number string to 10.

To add validations, go to Validation Rules tab. I add a validation to age, age should be always between 10 and 70.

And I add a regular expression to validate the email address. For that we have to select Regular expression option and create new regex. I add regular expressions to validate mobile number and email address and I make every field is a required field. And don’t forget to set error message to be popped up if the user enter wrong input.

The below image shows the all validation rules I added to Employee adding.

Okay. Now we have validated the input and if the user inputs it in wrong format, it shows a message.

Now think that we want to indicate the salary each employee get. This is decided by the level of the employee and age of the employee. How can we do that? Microflow does not provide more functionalities for us. Then what is the option? At this point, when we need much more complex logic, microflow is not enough. Then we have Java Actions. That is we can put some java code into our project.

When we go inside the Employee Details page, we need a button to get salary details. We select a ‘Call microflow button’, as we call a java action through a microflow. And create a new microflow for this.

From the above microflow we get the employee which comes from the Detail Page, and input it to the java action, then we show the return string from our java action in a pop up. Setting the Java action will be like below.

Now think this as another java method. What we want is to input an employee object to the input parameter and then compare the age and seniority, then decide the salary. Here input parameter is an object of type Employee. Return type lets say a string. In this string we return the desired salary for an employee.

Now comes the tricky part. Here, in mendix, we have to export this project to Eclipse to edit the java action. For that what we have to is, following the below steps.

Then open Eclipse and go to File → Import.

Then give the location we deployed our Mendix application.

Click on finish. Okay now you can see your project in Eclipse.

Let’s go to our Java action class and input our logic there. Find the // BEGIN USER CODE//END USER CODE block and input our logic inside that block.

To deploy the project just go to Run → Run configurations and start a new Java Application.

Then you’ll see the application is starting.

Okay now we have to check if it is working fine. After you finish the development, we have to sync our local changes with the project in web. For that, we have to commit all the changes. Go the Project → Commit. After giving a commit message, you can upload your changes to the web.

Yaayy!!! You improved your app using Mendix Desktop Modeler. Here I have used very simple use of the Java Action, but we can use it for do lot more. Explore more in the Desktop Modeler and you will find more in there. From app security you can add security to your app, from app settings you can change the server, database and many other configurations.

Enjoy Mendix!! Do bigger things 🙂

Reference :

  1. Mendix documentations
  2. Mendix forum

--

--