How to maintain the state of the object after the page is closed
Hi All, Am just starting out the development in mendix, How to maintain the state of the object which is passed on to the target page after its closed. Basically this is what am trying to do : Load Page –> Page -1 Create an Object → Inc Open a page → Page-2 Pass on the Object Inc to Page-2 Page-2 changes the value of one of the attribute in Inc Close the Page. When Page-1 is shown the cycle of new object creation is happening. Please note i dont want to persist the object in DB for easy retrival everytime.
The regular Mendix way is indeed storing the object in the db and retrieving it the next time. If you do not want to do that, for instance because you want to limit your dependency of the presence of the database, you will need your clientside to remember your object. This is probably possible by storing it in a cookie or a client’s local storage. Something that I have done by exception ages ago in php-web-applications, but never gotten around to trying this in Mendix.
Tim van Steenbergen
You can create an association between the current user and a non persistent object. In that way, you can retrieve this object from memory everytime you need it, in the same session.
Do this by
creating the non persistent object
creating an association between the object created in step 1 and 'Account'
Create retrieve flow Account_Retrieve, with a inheritance split on $currentUser
Set the Account path from the inheritance split to return the Account object. Set the other paths to return an empty object
When you have retrieved the account in a microflow from Account_Retrieve, retrieve the non persistent object over association. Make sure you handle empty objects from Account_Retrieve. F.e. MxAdmin does not have an Account object.
Now you can use this object on all pages, for each account, everything is stored in memory.
The data will be cleared after session logout of the account
Created persisted objects on the page can be associated to the non persistant helper object and commited on the final page, if you are trying to build a wizard or something like that.