SPEAK

MessageBar

Abstract

This topic describes how to use MessageBar component in SPEAK.

The MessageBar control displays messages to the user. You can add links to actions to a message. You cannot change the styling of a MessageBar control, and you cannot set the size of the control.

The MessageBar control shows Message items that you specify in the Messages property. You can add multiple messages to one MessageBar control by adding a pipe-separated list of Message item IDs in the Messages property. In this case, the MessageBar control shows the first message in the list of messages, and the rest of the messages are available when the user clicks the drop-down arrow that the MessageBar control automatically adds.

A Message item is a Sitecore item based on a MessageType template. There are three different MessageType templates:

  • Error Message

  • Warning Message

  • Notification Message

The three types of messages are styled differently, but have the same basic functionality. They have these fields:

  • Text – the message text

  • IsClosable – if True, users can close the message

  • IsTemporary – if True, the message closes automatically after some time (only the Notification message type has this field)

If you add multiple messages to a MessageBar control, the messages do not have to be of the same type.

A message can have one or more action links. You add action links by creating an item based on the ActionsLink template and adding the item to the Action field of the Message item. This item has two fields:

  • Text: the name of the link (this is what the user sees).

  • Action: the action that is triggered when the clicks the link. For example, this can be JavaScript.

You can add multiple action links to a message.

Sometimes you have to determine when to show the MessageBar control in either PageCode or by using rules, but there are simple scenarios where you can use other methods.

For example, if you have a dialog that shows a search result, and you use a SearchDataSource component to retrieve items. In this case, if the search does not find any items, you want to show a notification to the user.

To do this, you add a MessageBar control to the dialog and set IsVisible to False. You bind the IsVisible property of the MessageBar control to the hasNoItems member of the SearchDataSource component. When there are no items in the search result, the MessageBar control becomes visible and shows the notification.

Name

Description

Default

Data

Messages

Specify item IDs of the Message item that the MessageBar control shows. You can specify multiple messages as a pipe-separated list.

Configuration

You can create a configuration item for a MessageBar control by creating an item based on the MessageBar Parameters template.

The configuration item has these specific fields:

  • Messages

It inherits these fields:

  • IsVisible

  • AccessKey

  • Tooltip

  • Behaviors

  • Id