WebApp: Notifying the user

September 5, 2012 by Parag   Comments (0)

, , , ,

WebApp offers various ways of notifying the user that something has happened. It uses this, for example, to tell that it's currently sending the e-mail. In this case, the message is designed to be as unobtrusive as possible, but by contrast, the notification that your browser is not supported is more prominently placed. These kinds of messages can all be presented to the user by the notification framework.

The framework consists of a notifier object and notifier plugins. The plugins are the actual ways in which the user gets some useful information; they might be using message boxes or popup boxes or even only show output in the browser’s console.

Notifications are handled by the class Zarafa.core.ui.notifier.Notifier.  This is a singleton object that can be obtained from the global `container` object. All notifier plugins (subclasses of Zarafa.core.ui.notifier.NotifyPlugin) are registered to this object.

How to notify the user?

  1. Add/choose a category of the notifier.
    Choose any type of notifier from the setting 'zarafa/v1/main/notifier' whichever is apt for the notification, or else you can add a new type by adding it in the Zarafa.settings.data.SettingsDefaultValue class, under the settings path 'zarafa/v1/main/notifier'.
    The category should be like "type[.subtype]", where "type" should be: "error", "warning", "info" or "debug", and "subtype" can be any information string. An example is "info.newmail", so "type" is "info" and subtype is "newmail".
    Here, the notifier will get the name of notifier plugin from the setting 'zarafa/v1/main/notifier/type/subtype', if that setting is not available then in will fall back to 'zarafa/v1/main/notifier/type/', and if that is also not available, then it will fall back to 'zarafa/v1/main/notifier/default'.
    The name of the notifier plugin is set as value of the setting. E.g.: console, popup, dropdown, messagebox.
  2. Get the Notifier object.
    container.getNotifier() will return the singleton Notifier object.
  3. Choose a title and message string for the notifier.
  4. Provide a notifier container element in which the notice should be rendered, and possibly an animation effect like fadeIn, fadeout, slideIn, slideOut if required.

List of available built-in Notifiers: 

  • Console Plugin                  ->  Shows message in browser console can be used for debugging information. 
  • Dialog Notifier Plugin          -> Shows message popup in title bar of the dialog.
  • Dropdown Box Plugin         -> Shows message in a dropdown box in the top-middle of the screen.
  • Message Box Plugin          -> Shows message in messagebox.
  • Persistent Message Plugin -> Shows message at top middle of the screen, which hides  when user clicks on the message.
  • Popup Box Plugin              -> Shows message popup in the lower right side of the corner.

An example of the Persistent message plugin Notifier, at the top center, which notifies the user that his current browser is not supported by WebApp.
 An example of the Popup Box plugin Notifier, at the bottom right, which notifies the user that new mail has arrived.

How to create new Notifiers?

If you need a new way of presenting a notice to the user that's not present in one of the default plugins, then you can create a new NotifyPlugin.

  1. Extend your notifier from Zarafa.core.ui.notifier.NotifyPlugin
  2. The notifier plugin must override the abstract method named 'notify'. This method is called when the notifier should be shown.
  3. Register the notifier plugin to the singleton Notifier object.
    E.g.: container.getNotifier().registerPlugin('exampleplugin', new Zarafa.core.ui.notifier.ExamplePlugin());

Now you can use this notifier as mentioned before.

Be careful with the amount of notifications. If too many notifications are used, they're no longer as useful. If you need them for debugging purposes, then you can always use the console plugin.