Displaying Messages to Your Users

The minimessage library enables the developer to display a message window to a user. This is a valuable feature when you’re trying to obtain user input or display status messages to a user that autodismiss after a short interval.

To integrate this feature, take the following steps:

  1. Within the ModulePrefs node of the gadget spec file, add a Require element to enable the minimessage JavaScript library.

    • Include: <Require feature="minimessage"/>

  2. Within the gadget JavaScript layer, insert an initialization function for the mini-message features.

    • Method call: var message = new gadgets.MiniMessage(__MODULE_ID__);

  3. When you wish to create a new message window, call one of three message window request methods.

    • Dismissible message: message.createDismissibleMessage("My Message", callback);

    • Static message: message.createStaticMessage("My Message");

    • Timer message: message.createTimerMessage("My Message", 3, callback);

As noted in step 3, there are three different message types that a gadget implementer may specify:

Dismissible message

Remains visible until the user manually closes the window.

Static message

Remains visible until the code-specified event occurs. This message may be dismissed only via the gadget code.

Timer message

Remains visible until a predefined timeout occurs. These messages will autoclose when the allotted time expires.

Moving from basic concepts into functional examples, next we’ll explore how to build and customize message windows using the available JavaScript library methods.

Get Programming Social Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.