Java change object attribute value

2
How can i in Java change an objects value without having to commit it to the db. I only want to change it in the memory. I want to set in a java action an id which is set when an object is created however i do not want to commit this until the user has pressed save. I have tried using this line of code: object.setValue(this.getContext(), attributeName, value); It does not throw out any errors and seems to change the field however this is not being displayed on the screen when the form is opened. I need some way in the java to change the cache object not the db object before it gets committed.
asked
2 answers
5

You have to use Core.change (http://apidocs.mendix.com/runtime/classcom11mendix11core11_core.html#a883040302bab2117b8b64f3765e0ae5f) to update the object in the cache too. If you don't use that then you'd have to commit first or return the object from your java action and show that.

Then refresh like Herbert says.

answered
2

Hi Simon, Most likely you have to let the framework now that the object has to be refreshed in the client (the Java way of the refresh in client check box). You can do that within an action with:

this.addRefreshObjectFeedback(object.getId());

An easier way for changing members is to use the proxy's, generated by the framework. If your object is a Person for example you can do something like this: Person person = Person.initialize(object); After that you can use the person.set and person.get functions.

answered