Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Include Page
_What is an alert
_What is an alert
 

为显示告警,您需要注入

Javadoc
0info.magnolia.ui.api.context.UiContext
界面到您的类中。UiContextAppContextSubAppContextShell来实现,所以如果您手边正好有其中的一个或多个,可以直接重用。

使用样例:

Code Block
languagejava
@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);