Java - how to instantiate new instance of entity?

0
Hi! I have an entity in the domain model and want to retrieve data from an external source. I try to use a java action for this task. The java action should return a list of that entities to be displayed in a data grid or list: Create new instance of entity set attributes add new instance to return list   The question is how can I create a new instance and populate it with data? My current code: List<IMendixObject> returnList = new ArrayList(); IMendixIdentifier mendixIdentifier = null; IMendixObject __Select3 = Core.instantiate(getContext(), "Select3"); which results in  com.mendix.core.CoreRuntimeException: 'Select3' is not a valid entity   Thank you!
asked
2 answers
6

Hi Erwin,

You should include the module name as well eg Core.instantiate(context, "System.UserRole")

Kind regards,

Jeroen

 

Edit: To give a more complete answer: use __Select3.setValue() to modify this object. 

Also note that using plain text strings will work but is not recommended. You can better import the Proxy for the entity:

Under imports add a line:

 import YourModuleName.proxies.Select3;

And use: Core.instantiate(context, Select3.entityName)

This way when your entity name changes you do not have to change your Java code.

answered
0

Why use JAVA in the first place?

answered