Refresh a screen datasource if the datasource items have been changed externally


Use case i’m trying to implement :

  • create a product (editor)
  • when you select product family (using a dedicated ds) some other product fields are initialized with content of product family fields (implemented)
  • discover you need a new product family and create it another screen/tab while keeping product editor open
  • the new family should be available in the still opened product editor screen

By default this does not work of course, because the product family datasource behind the product editor has to be refreshed.

The macro design of a solution would be sending some signal <> from the product family editor once new family is saved. Signal should be heard from product editor which would then refresh its product family ds.

Is there a standard way to implement this in CUBA ? I was thinking about BlackBoard or Google EventBus but maybe there is already an internal system alike in the platform.


Hi Michael,
There are no general purpose event dispatching mechanisms in the platform, but there is a dependency on Guava library, so you can easily use their EventBus. Just create a managed bean in the web module and put an instance of EventBus there. As long as you post events from the request thread, refresh of datasources should work well. If you need an asynchronous processing, use background tasks or UIAccessor interface.

Great, thank you Konstantin.