Update open browser tab from routine within ExtAppMainWindow?

I have a main process start when I click a button within ExtAppMainWindow. Sometimes, I will have browser tabs open when I start the routine but not always. Is there a way to force an update to the open browser tabs? I currently manually update the tabs but would like to have it automatic, so the user doesn’t inadvertently use stale data.

I tried to put collectionchangelisteners in my browser tab source code and I have also tried to trigger a datasource refresh (injecting the UI screen) from the ExtAppMainWindow. Neither approach appeared to have any effect. Forum Item 1652 seems similar but there didn’t seem to be any workarounds at that time.

Hello @njmckenzie20004446

Could you clarify the difference between manual and automatic update in this case? Unfortunately, I don’t understand the essence of the problem

Regards,
Daniil

Daniil,

In my application, I have a routine which is triggered from a button within the main widow (called ExtAppMainWindow which extends AbstractMainWindow). This routine uses and changes a wide variety of data in the database.

I also have data input/output screens which are linked to the database. My screens are all arranged as tabs when they are opened. The manual update of these tabs/screens refers to either me pressing the Refresh button on the screen (which was automatically created when using the cuba studio Generic UI templates) or manually closing the tab/screen and reopening it.

Conversely, I also have a couple routines which are triggered from buttons on individual tabs/screens. Within these routines, I can include datasource refresh statements which ensures that the UI is updated with the latest information. I call this code driven datasource refresh my automatic method.

I would like to know if it is possible to find (from within a routine in ExtAppMainWindow) which screen/tabs are open and trigger a datasource refresh for those tabs/screens.

Sincerely,
Nate

I suggest you to use Events mechanism to send an event when data is updated and subscribe in screens for it to perform automatic update.

Thank you Daniil,

That looks like a good avenue to follow. I was able to implement the event publisher in the ExtAppMainWindow and properly receive it in the UI controller. However, when I perform the datasource refresh within the UI controller, I get the following error: UI Shared state was accessed from a background thread.

I see a similar error message was received for forum topic: UI Shared state was accessed from a background thread - CUBA.Platform however, the problem seems pretty different. Do you have any recommendations on how to troubleshoot this error?

Sincerely,
Nate

In fact suggested solution in related topic should be suitable for you. Please try to use it and give a feedback