fbpx

How to Invoke a JAVA Action in Mendix

Java Action is a resource in Mendix which allows you to build complex backend logic by writing code in Java and exposing it through a custom Java Action. This can then be used within a microflow to perform the complicated task. Mendix Project can be exported as an Eclipse General Project and then we can start writing our Java Action in Eclipse IDE. The Java Action in Mendix which we create can accept Parameters as Input and can return an Object (which inherits iMendixObject in Java). This returned Object can be processed further in Microflow. Click here for detailed steps on adding a new JAVA Action in Mendix. Import the eclipse project in Eclipse IDE and edit the Java action as required. As depicted below we have an overridden method executeAction() which is invoked whenever our Java Action is executed in Mendix. You can add your custom code in between the Commented lines Begin User Code and End User Code.

In this example, character count is taken as an input parameter and Alpha Numeric String consisting of the letters A-Z and Number 0-9 is generated. The length of the final string will be equal to the input Character count.

Tailored Java operation in Mendix

Invoking the Java Action in a Microflow

Create a basic page  in Java action in Mendix which takes the Character count integer as Input and on the click of generate button, call a microflow which in turn calls the Java action and returns and displays the String.

In the microflow, call the Java Action using the Java Action Call widget and then use the returned String value to display it in the Text box in the Page.

Creation of character count integer in Mendix Java operation
Mendix is made up of microflows which express the logic of your application

Character Count as Input and set the Return value as in below screenshot.

Character Count as Input and set the Return value in Mendix Java action

Deploy the Mendix App and Test the Java Action

Enter any Number between 1 to 25 in Character Count field and click generate Button.

Count –> 15

Mendix Software deployer and Monitor the Java Activity

Count –> 25

25 character Mendix Software deployer and Monitor the Java Activity

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu