Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.

Alerts are modal messages that show up in the context the user is currently working in. You can use alerts to confirm that an action should be executed, inform the user of harmful consequences, or report the progress of a long-running action. Since alerts are modal they block the user interface. 

To show alerts, inject the 

$webResourceManager.requireResource("info.magnolia.sys.confluence.artifact-info-plugin:javadoc-resource-macro-resources") UiContext
 interface to your class. The UiContext is implemented by AppContextSubAppContext and Shell, so if you have one of those at hand, just reuse them.

Usage examples: 

public MyCustomClass(UiContext uiContext) {
   this.uiContext = uiContext;
// Show an ERROR alert.
private openErrorAlert(String message) {
   uiContext.openAlert(MessageStyleTypeEnum.ERROR, "Error", "File upload failed.", "OK", null);
// Confirm deletion with a WARNING alert.
private openConfirmationWarning(String message) {
   uiContext.openConfirmation(MessageStyleTypeEnum.WARNING, "Delete node?", "This action cannot be undone.", "Yes, Delete", "No", true, null);
  • No labels