Java Programming

2 minutes to read Download PDF Edit

With Java actions you can extend the functionality of your application in situations where it would be hard to implement this functionality in microflows.

For information about Java actions in the Modeler see Java Actions.

Writing code in the .java files of your Java actions

In the .java files of your Java actions you can write your Java code between the markers:

  • // BEGIN USER CODE and // END USER CODE
  • // BEGIN EXTRA CODE and // END EXTRA CODE.

This is explained in more detail below.

The other code in these files is regenerated each time when you deploy your model, thus any modifications that you make in them will be overwritten. Your imports will be preserved however.

The method executeAction is called by the runtime when the Java action is being executed. Between the lines // BEGIN USER CODE and // END USER CODE you can write your custom code that will always be called when executing the action. In this method you can call other methods in the section between // BEGIN EXTRA CODE and // END EXTRA CODE.

The executeAction method throws all exceptions that occur. This means you can do error handling in the microflow calling this Java action. If you’d like to do your own error handling within the action, use try/catch statements.

Using the Mendix Java library

In the Java code that you write for your Java actions you can use the Mendix Java library.

This library is automatically added to your libraries when you imported your project into Eclipse and it is called mxruntime.jar.

A tutorial with some examples can be found at the Java API Tutorial page.

Using Eclipse as an environment to write your Mendix Java actions

See Using Eclipse.

Java actions in the cloud

See Java in the Cloud.

Documents in This Category

Copyright © Mendix. All rights reserved. | Mendix.com | Terms of Use | Privacy Policy