*Legendary answered* How to get results of GetMicroflowNames from a Java Action?

Hi guys I am exploring the inner workings of Java api of Mendix and wondering how to get the following working in a Java action:   public static java.util.Set<java.lang.String> getMicroflowNames() Returns the names of all modeled microflows. Returns: all microflow names (format "ModuleName.MicroflowName").  I have a Microflow with a Java action where there is no input, but I am wondering what the output should be. Inside my Java action I have this code: Core.getMicroflowNames(); return String; 1 - What should I understand with public static java.util.Set<java.lang.String> getMicroflowNames()? does this imply that I have to give a string as input which outputs a string in the given format? 2 - What should the java action be to get a whole list of strings/objects with the names?
3 answers

Hi Enzo,

  1. The definition of that method says that it takes no inputs, and returns a Java Set of String objects. 
  2. The trick here is that you cannot return a list of strings from a Java action to Mendix. So, you must either:
    1. Concatenate all of the strings together into a single string
    2. Create a list of Mendix objects, with an attribute representing the string from the original set


Chris recommended the ModelReflection module because it does exactly what I describe in number 2 above. I've created a simple module that you can download, import, and try yourself. It contains a java action and one page. Add the page to your project navigation menu and give it a try. 


For reference, the java action code is:

List<IMendixObject> microflowObjs = new ArrayList<IMendixObject>();
IMendixObject obj;
for(String microflowName: Core.getMicroflowNames())
	obj = Core.instantiate(getContext(), "SimpleModelReflection.MxMicroflow");
	obj.setValue(getContext(), "CompleteName", microflowName);
	microflowObjs.add( obj );

return microflowObjs;


Hope that helps!


Looking at your question number one: if you do not know or understand the way functions are defined in Java (including their input parameters and output type) you should really do some research first, e.g. by looking at: the first Google hit for 'Java function definition'

To answer your question number two: Core.getMicroflowNames() returns a set of strings. You can iterate over the set, and for each element create a Mendix object, set an attribute on the object with the microflow name, add the object to a list and return the list. Alternatively, if this sounds rather complex, you can use the model reflection, like Chris suggested, and retrieve the microflow names from the database. Model reflection also contains the code the map microflows, and this code can be found in /javasource/mxmodelreflection/metamodelBuilder/MicroflowBuilder.java


See appstore module modelreflection