Send messages from service to gui


Is there any way send notification from service to web layer. In web layer I’d like
show notification witch was send from service. Can I use events mechanism for it ?


The global events addon allows you to do that: Global Events – CUBA Platform

Another approach is done in the user-inbox addon, which is based on polling: User Inbox – CUBA Platform

I hope this helps…


Hi Mario

I try implement global events, code in java is below. I publish event, but I don’t know How I can receive event in web layer and
show notification.

public class DocumentNumerationServiceBean implements DocumentNumerationService {
	private Persistence persistence;
	private int NUMBER_LEN = 40;

	private Events events;
	private UserSessionSource userSessionSource;

	public String getNextNumber(String numberMaskCode, Date date, String documentType) {

		String result = null;
		try (Transaction tx = persistence.createTransaction()) {
			EntityManager entityManager = persistence.getEntityManager();
			NumeratorManager nm = new NumeratorManager(entityManager, NUMBER_LEN, null, null);
			result = nm.getNextNumber(numberMaskCode, date, documentType, null);
			UserSession userSession = userSessionSource.getUserSession();
			events.publish(new MyUiNotificationEvent(userSession.getUser(), "message Hello"));

		return result;


Take a look at the demo project GitHub - cuba-platform/global-events-demo: Global Events add-on demo project

You can receive global events in screen controllers:

public class Screen1 extends AbstractWindow {

    private static final Logger log = LoggerFactory.getLogger(Screen1.class);

    private Label receivedLab;

    private AtomicInteger count = new AtomicInteger();

    public void onUiNotificationEvent(UiNotificationEvent event) {"Received {}", event);

For instance, you could extend the main window and add event handler there.