How do I make the Calendar widget update when the source data changes?

I'm having trouble understanding how the Calendar Widget in Mendix works in terms of refreshing data. But one step at a time.   My domain model looks like the following The data in AnyEntity1 and AnyEntity2 are very different but are generally about events and I want to display them together on the calendar. [worth noting: there are more than 2 AnyEntities]. So I created a Calendar helper entity that de facto stores variables to hide the selected data (the user can enable or disable AnyEntity1 or AnyEntity2 data). It's a 1:1 association entity but it helps me keep the design readable. (Originally the Calendar entity was also non-persistent because it is only used to display data at the appropriate time but at some point I thought there was a bug in that so I changed it to persistent) A microflow was created which collects this data, processes it accordingly and for each event from AnyEntity1 and AnyEntity2 associated with the MainEntity object, creates a corresponding event in the Events entity associated with Calendar (which is essentially meaningless since this is returned as a list) and then returns it as a list of Events objects. This microflow is run as the source of the Calendar widget. And until then, of course, everything works properly.  However, if on the page (e.g. when the user clicks a button) the user removes an event from e.g. AnyEntity2 then the microflow should restart and collect this data again and display it in the calendar. Similarly when a new item is added to either of the two AnyEntities. And here's the problem: I don't know how to trigger such an action and Calendar won't do it by itself. You have to reload the page for the changes to be displayed - and then all the set data is visible. So my question is: is there any way to automatically refresh or react in linked objects? Of course, one solution is simple: call microflow every time an item is added or removed from an AnyEntity entity, but that would overload the system considering how rarely this calendar is used in the end. Do you have any solutions on how to change the domain model and data structure / microflow to make it work more efficiently and dynamically? PS. Strangest of all, the widget cannot be linked to the database via XPath or via Context - both of these functions do not work. You can only select a specific object from the database. I don't understand why...
1 answers

Hi Marc,


It is possible in widgets that can be refreshed without refreshing the whole page (for example, grid using the “listen to widget” option ) all others need a page refresh. You can do that using the non-persistent entity object as a page parameter of the page and passing it while opening the page. 


I use this in data-driven applications where the GUI element texts are stored in the database or for graphs. This makes it highly flexible. I use nanoflows for it to keep away as much load on the server as possible. 


Go Make It