Java actions which return enumeration values

4
I've got a Java action which decides which of three states an object falls into. If I try to declare the java action so that it returns an enumeration Mendix seems to generate a stub which extends UserAction<string> and returns a String instead of the enumeration values. Is that correct behaviour, and how can I turn this string into the wanted enumeration value?
asked
1 answers
3

This is indeed the correct behaviour. An enumeration is nothing more than a list of String values where you can choose from. For a correct return value you can do the following in your first action that determines the value:

return String.valueOf(Enumeration.value);

In the other Java action you can get the value of this enumeration and use it like this:

Enumeration type = Enumeration.valueOf(JAVAaction.executeAction());

type will hold the value of the enumeration.

You can use this in I.E.

Switch (type){

case One:
       // do something
       break;
case Two:
       // do something
       break;
default:
       // do nothing
      break;
}
answered