+

Search Tips   |   Advanced Search

Display messages using the status bar module

Display messages using the status bar module.

All ready-to-use theme profiles include the status_bar module, which provides an area beneath the header for displaying error, warning and information messages. The following image shows an example error message in red.

  1. Add a line of JavaScript to use this status bar in the themes, modules, and portlets can use this status bar.

      i$.fireEvent("/portal/status",[{message: new com.ibm.widgets.StatusMessage ("error", "The specified name is in use. Please enter a unique name.", ""), uid: 'ibmStatusBox'}]);

    i$.fireEvent is the recommended syntax. However, if we use the Dojo module, we can also use this alternative syntax:

      dojo.publish("/portal/status",[{message: new com.ibm.widgets.StatusMessage ("error", "The specified name is in use. Please enter a unique name.", ""), uid: 'ibmStatusBox'}]);

    1. The first argument in the StatusMessage can be either "error", "warning" or "info" to control the icon and color of the message box.

    2. The second argument in the StatusMessage is a String representing the message itself to be displayed in the message box.

    3. The third argument in the StatusMessage is an optional String representing any further details about the message. The details are not presented to the user by default, rather only if the user clicks the Show Details icon to expand the message box.

  2. If we have an error that originates on the server, set error cookie...

      ibm.portal.operations.error

    ...in the response, and the client shows the message when the response completes. Use parsable JSON code for the cookie string value, such as:

      ibm.portal.operations.error={"errorType":"error","errorMessage":"The specified name is in use. Please enter a unique name.","errorDetails":""}

  3. Messages are cleared automatically on page reload. To clear one or more messages from the client using JavaScript...

      i$.fireEvent("/portal/status/clear", [{message: mymessage, uid: 'ibmStatusBox'}]);

    ...where mymessage is the StatusMessage instance you saved when displaying the message. Code like the following example is fine too:

      i$.fireEvent("/portal/status/clear", [{message: new com.ibm.widgets.StatusMessage ("error", "The specified name is in use. Please enter a unique name.", ""), uid: 'ibmStatusBox'}]);

    The event clears any messages whose StatusMessage type, message, and details strings match, so we do not have to reuse the same actual StatusMessage instance.

    If no StatusMessage is passed, then it clears all messages. We can clear everything with the following code sample:

      i$.fireEvent("/portal/status/clear", [{uid: 'ibmStatusBox'}]);


Parent Customize the theme