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  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);
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels

1 Comment

  1. When I use a null as AlertCallback, a NullPointerException is thrown. Is this example still valid in version 5.6.x? I recommend a () -> {}