Hi,
Using a string as Rob suggests will work just fine but it has a major drawback IOP.
If the enum definition is changed or removed then you will not notice this until you run your java action.
An easy way around this is to use the proxies that mendix generates for you.
For example:
system.proxies.DeviceType.Phone.name();
Hope this helps,
Andrej
Hi Martin,
As you discovered, an enumeration is just a string. The Mendix platform will convert it to the right enumeration for you so it is much easier than you think. For example, if I have a java action that returns the Enumeration System.DeviceType enumeration, all I need to do is have my Java action return the string "Phone" and the Mendix platform will map that to the enumeration value automatically. I haven't done a complete set of tests to see if the matching is case sensitive or if it will map to the Name as well as Caption, but just return the enumeration value you want as a string. In my example, the following Java code is enough for my Java action to return, in a microflow, the DeviceType.Phone enumeration value.
public class getDeviceType extends CustomJavaAction<java.lang.String>
{
public getDeviceType(IContext context)
{
super(context);
}
@Override
public java.lang.String executeAction() throws Exception
{
// BEGIN USER CODE
return "Phone";
// END USER CODE
}
/**
* Returns a string representation of this action
*/
@Override
public java.lang.String toString()
{
return "getDeviceType";
}
// BEGIN EXTRA CODE
// END EXTRA CODE
}