Java actions not returning a value - Mendix Forum

Java actions not returning a value

3

I would like the option that java actions do not return a value, so I don't have a useless boolean returned. And I don't want to declare a useless variable in the microflow, see other idea!

asked
1 answers

Great to see such a basic feature implemented!

Unfortunately, I struggle with the implementation of returning nothing a bit.

If I select ‘Nothing’ as return type in my Java action, the signature of the stub that gets generated looks like:

public java.lang.Void executeAction() throws Exception

If I leave out any `return;` statement, or use `return;` without a value, the compiler complains (missing return value).

According to the JavaDoc, Void is an uninstantiable placeholder class, so I also cannot write `return new Void();`.

What is the intended way to implement a Java action that returns Nothing?

Edit

Ok, I figured it out by myself now. Of course `return null;` works – but not the most intuitive thing when your mindset is to implement a void method.

Created