Customizing or replacing Notifications

Our users mentioned that there are many types of Notifications (TRAY, SYSTEM, ERROR, etc). To make it consistent, they wanted a single type of notifications for all messages. E.g. no more Tray notifications.

I want to customize this but I noticed that “notifications” is defined in the AppUI class:

    Notifications notifications = new WebNotifications(this);
    autowireContext(notifications, applicationContext);
    setNotifications(notifications);

Is there a way to override “notifications” to use my “customized” version of WebNotifications ?

CK

Hi,

In order to replace WebNotifications with your custom implementation, you need to do the following:

  1. Extend AppUI and override the setApplicationContext() method in which set your custom Notifications implementation:
public class CustomAppUI extends AppUI {

    @Inject
    @Override
    protected void setApplicationContext(ApplicationContext applicationContext) {
        super.setApplicationContext(applicationContext);

        Notifications notifications = new CustomWebNotifications(this);
        autowireContext(notifications, applicationContext);
        setNotifications(notifications);
    }
}
  1. Register CustomAppUI in web-spring.xml
<bean id="cuba_AppUI" class="com.company.demo.web.CustomAppUI"
      scope="prototype"/>

Regards,
Gleb