Java source file overwritten

7
I'm writing a Java action by inserting code into the automatically-generated executeAction() method in the Java source file which Mendix produces when you first create a Java action. When I try to deploy the application the file gets overwritten with the template action file, which does nothing. I've saved the file, deleted it and regenerated it and inserted my code again, but it keeps getting overwritten with the template. I thought once you saved a piece of your own code in this file Mendix left it alone and just compiled it, so does anyone know how to stop this?
asked
2 answers
8

You need to only insert lines between the

// BEGIN USER CODE

and

// END USER CODE

lines. If you do that they won't be overwritten. The result should look something like this:

public Boolean executeAction() throws Exception
    {
        // BEGIN USER CODE
        System.out.println("Hello world!");
        return true;
        // END USER CODE
    }
answered
6

As an addition to the answer from Achiel: You can also put code between the // BEGIN EXTRA CODE and // END EXTRA CODE at the bottom of the file. This can be very handy for writing your methods.

answered