Some weird changes in the Java code

2
I am workin in a model and when trying to run the model I suddenly get a java error code that a compilation failed. So I started Eclipse and this is what I found. It complained about not finding __TokenObject in ReplaceToken.java. This is the code I found: // This file was generated by Mendix Business Modeler 4.0. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. // Special characters, e.g., é, ö, à, etc. are supported in comments. package mxmodelreflection.actions; import mxmodelreflection.TokenReplacer; import com.mendix.systemwideinterfaces.core.IMendixObject; import com.mendix.systemwideinterfaces.core.UserAction; /** * Search the parameter text for the token fromt the parameter TokenObject, replace the value with a value from the parameter ValueObject. */ public class ReplaceToken extends UserAction<String> { private IMendixObject __TokenObjectParameter1; private mxmodelreflection.proxies.Token TokenObjectParameter1; private IMendixObject ValueObject; private String Text; public ReplaceToken(IMendixObject TokenObjectParameter1, IMendixObject ValueObject, String Text) { super(); this.__TokenObjectParameter1 = TokenObjectParameter1; this.ValueObject = ValueObject; this.Text = Text; } @Override public String executeAction() throws Exception { this.TokenObjectParameter1 = __TokenObjectParameter1 == null ? null : mxmodelreflection.proxies.Token.initialize(getContext(), __TokenObjectParameter1); // BEGIN USER CODE return TokenReplacer.replaceToken(this.getContext(), this.Text, this.__TokenObject, this.ValueObject); // END USER CODE } /** * Returns a string representation of this action */ @Override public String toString() { return "ReplaceToken"; } // BEGIN EXTRA CODE // END EXTRA CODE } Now I had a very recent branch from this same model. There the code was this: // This file was generated by Mendix Business Modeler 4.0. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. // Special characters, e.g., é, ö, à, etc. are supported in comments. package mxmodelreflection.actions; import mxmodelreflection.TokenReplacer; import com.mendix.systemwideinterfaces.core.IMendixObject; import com.mendix.systemwideinterfaces.core.UserAction; /** * Search the parameter text for the token fromt the parameter TokenObject, replace the value with a value from the parameter ValueObject. */ public class ReplaceToken extends UserAction<String> { private IMendixObject __TokenObject; private mxmodelreflection.proxies.Token TokenObject; private IMendixObject ValueObject; private String Text; public ReplaceToken(IMendixObject TokenObject, IMendixObject ValueObject, String Text) { super(); this.__TokenObject = TokenObject; this.ValueObject = ValueObject; this.Text = Text; } @Override public String executeAction() throws Exception { this.TokenObject = __TokenObject == null ? null : mxmodelreflection.proxies.Token.initialize(getContext(), __TokenObject); // BEGIN USER CODE return TokenReplacer.replaceToken(this.getContext(), this.Text, this.__TokenObject, this.ValueObject); // END USER CODE } /** * Returns a string representation of this action */ @Override public String toString() { return "ReplaceToken"; } // BEGIN EXTRA CODE // END EXTRA CODE } Now can somebody explain to me why _TokenObject is suddenly replaced by _TokenObjectParameter1? I looked in the model and the name of the parameters in de MxModelreflection module was not changed. And why did it only change the name OUTSIDE the //BEGIN USER CODE but not inside and thus resulting in a compilation error? What is causing the trigger for the name change? Regards, Ronald
asked
2 answers
4

The Modeler adds 'Parameter1' to the name of a parameter if there is an entity or enumeration that would cause confusion with the parameter name. So, if your parameter is called 'Foo' and there is also an entity called 'Foo' then the Modeler will turn the parameter name into 'FooParameter1'.

So, you probably added an enumeration or entity to the project that is called 'TokenObject'. The solution is to change the user code to also use the 'Parameter1' extended name.

This behavior, of course, is not desirable, you might even call it a bug :-)

answered
0

Todaay I had also this problem which is around for some time...  Spontanious change by mendix of param names... Why is this not fixed???

answered