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.

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: 

@Inject
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