The 5.7 branch of Magnolia reached End-of-Life on December 31, 2023, as specified in our End-of-life policy. This means the 5.7 branch is no longer maintained or supported. Please upgrade to the latest Magnolia release. By upgrading, you will get the latest release of Magnolia featuring significant improvements to the author and developer experience. For a successful upgrade, please consult our Magnolia 6.2 documentation. If you need help, please contact info@magnolia-cms.com.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Banners are messages that inform the user about system and app events. Banners are displayed prominently at the top or bottom of the Magnolia shell. They capture the user's attention effectively but do not interrupt what the user is currently working on. Banners are the only persistent message type. The user can safely close the banner and read the full message in the Pulse later.

Showing a banner message in app code

To show a banner message:

  1. Inject AppContext or SubAppContext into your class so that you can access the messaging convenience methods. 
    Alternatively, use getAppContext or getSubAppContext inside your App or SubApp classes. If you extend the BaseSubApp you always have access to getAppContext and getSubAppContext.
  2. Create a new 
    $webResourceManager.requireResource("info.magnolia.sys.confluence.artifact-info-plugin:javadoc-resource-macro-resources") Message
     object . Pass the
    $webResourceManager.requireResource("info.magnolia.sys.confluence.artifact-info-plugin:javadoc-resource-macro-resources") MessageType
     only if you want to do your own message types.
@Inject
public MySubApp(SubAppContext subAppContext, MyView view) {
   super(subAppContext, view);
   view.setListener(this);
}
 
@Override
public void handleGroupMessage(final String group, final MessageType type, final String subject, final String message) {
   getAppContext().sendGroupMessage(group, new Message(type, subject, message));
}

Showing a banner message to a named user

AppContext provides convenience methods for sending messages. The user will be notified instantly with a popup if they are currently signed in. In any case, the message is stored in the Pulse as unread.

void sendUserMessage(String user, Message message);

Showing a banner message to all users in a group

The users in the group will be notified instantly with a popup if they are currently signed in. In any case, the message is stored in the Pulse as unread.

void sendGroupMessage(String group, Message message);

Showing a banner message to the current user

The following code snippet does the same as shell.showNotification(messageText).

private void sendToCurrentUser(String messageText) {
   final Message message = new Message();
   message.setMessage(messageText);
   message.setType(MessageType.INFO);
   messagesManager.sendLocalMessage(message);
}

Broadcast a banner message to all users

The users will be notified instantly with a popup if they are currently signed in. In any case, the message will be stored in the Pulse as unread.

void broadcastMessage(Message message);

See MessagesMainSubapp.java for examples.

Showing a banner message using the Messages app

The Messages app is a tool that allows you to send messages to individual users, groups or all users. You can find the app in the Dev group. The Dev group is only available to the superuser role by default, as configured in app launcher permissions.

The sent message is displayed in the Pulse.

  • No labels