How to create and set a IMendixObjectMember to a IMendixObject?

3
I have an IMendixObject and need to set the value of one member (IMendixObjectMember) inside it, is there any option or solution on how to do it? My entity Person, has an association with entity Phone (List of Phones). May I set the value of the list of phones inside a person, within a java action?
asked
4 answers
1

One way to resolve this issue is to use a many-to-many association, so browsing through the association will enable you to achieve this goal.

answered
3

I found out a solution.

I had to make the association between Person and Phone as * – * and navigability refer each other.

Then on java, you can create a list of Phone and attach it to the person entity you need.

In Mendix java action, my return was set to Object of Person, then inside the java action you need to use method  person.getMendixObject() as the return.

answered
0

You would normally use the proxy classes to do this.

So assuming you have an entity called Test in MyFirstModule, with an attribute called Name, and your IMendixObject is TestIMendixObject, something like this should work.

Test test = myfirstmodule.proxies.Test.initialize(getContext(), TestIMendixObject);
test.setName("my test object");

Hope this helps.

answered
0

If you’re setting a reference set (many-to-many), you’re looking for the setValue method on the IMendixObject. If you’re unsure about what to set the value to, try using getValue to read a current value so you can match it.

If you’re setting a reference (many-to-one), you need to iterate through each Phone proxy object or IMendixObject to set the association.

answered