Sharing variables between Java Actions

0
Hello, I’m currently trying to share variables between Java actions but I’m not sure if it’s doable in any other way than what I’m doing right now. Some of my current usages are a Map of objects and an object from a library I’m using. To do this I’m creating static variables in a public class which I can then use in my Java actions. I do believe my approach is flawed in security however I am not sure if there is another way to implement what I want. Is there anything I’m missing in Mendix that anyone can point me to to solve my problem, or if you have a better way for achieving my goal mentioning it would be much appreciated.   Thank you beforehand 
asked
3 answers
1

I don’t think the best solution is sharing data between two Java Actions. Each Java Action has it’s own scope, so I think it’s better to pass the data from your microflow to your Java Action. The same for your other Java Action: pass the data from your microflow to your Java Action.

answered
1

Even though this is not the first approach you should choose, you can attach data to the current context:

https://apidocs.rnd.mendix.com/8/runtime/com/mendix/systemwideinterfaces/core/IContext.html#getData()

This data will be available within the current execution context (e.g. a single web request from the client).

regards, Fabian

answered
0

Can you make sure the output of the Java Action has exactly the information you need to pass from the one action to the other? You would need to create interface objects in Mendix for this output, but then you can keep it lean and only pass the specific information needed.

answered