Best practice of communication between different components?

HI,

I have 3 different tables on a single view. Each table depends on the selection of the upper ones, and should change accordingly whenever a selection has been made in any of the tables.

Which is the best way, with respect to separation of concerns, to let the tables “talk” to each other?

Would a Guava EventBus thing be best choice? Or should I maybe just pass all table instances to a global presenter, which handles all ItemSelectEvents and updates the tables manually on any select?

Hi,

it depends on your usecase. You can build one Component which includes your three table. Inside of your new “blackbox” you can fire and handle the table events. The blackbox can fire a new event to indicate a state change.

Your decession could depends on the following points.

  1. Is it possible to build a composite component, then you should do it and build the new component as blackbox.
  2. Is necessary to handle the fired event as global event (login,logout,select language), then you should use a eventbus (CDI,Blackboard, Guava).

Tip for Eventbus: I use a combination of commands and controller to work with global events. A LoginController is the eventhandler and will execute LoginCommand and a PageViewCommand. This works great for me.