public class AlertBuilder extends Object
AlertBuilder
assists in opening alerts and confirm-dialogs in Magnolia.
Usage starts from either of the following static methods:
After that, body, callbacks, level and button captions may be configured through fluent builder-style methods.
Finally, the AlertBuilder
has two terminal operations,
both returning a standard Vaadin Window
component, ready to use.
build()
returns the Window
but does not open it;buildAndOpen()
returns the Window
and opens it in the current UI
Example:
AlertBuilder.confirmDialog("Say hi?") .withLevel(Notification.Type.HUMANIZED_MESSAGE) .withBody("Do you want to say hello?") .withOkButtonCaption("You bet") .withDeclineButtonCaption("No way") .withConfirmationHandler(() -> sayHello(name)) .buildAndOpen();
Modifier and Type | Method and Description |
---|---|
static AlertBuilder |
alert(String title) |
com.vaadin.ui.Window |
build() |
com.vaadin.ui.Window |
buildAndOpen() |
static AlertBuilder |
confirmDialog(String title) |
static AlertBuilder |
confirmDialog(String title,
Runnable confirmationHandler) |
AlertBuilder |
withBody(String body) |
AlertBuilder |
withConfirmationHandler(Runnable confirmationHandler) |
AlertBuilder |
withConfirmButtonCaption(String confirmButtonCaption) |
AlertBuilder |
withContent(com.vaadin.ui.Component content) |
AlertBuilder |
withDeclineButtonCaption(String declineButtonCaption) |
AlertBuilder |
withLevel(com.vaadin.ui.Notification.Type level) |
AlertBuilder |
withOkButtonCaption(String okButtonCaption) |
AlertBuilder |
withTitle(String title) |
public static AlertBuilder confirmDialog(String title)
public static AlertBuilder confirmDialog(String title, Runnable confirmationHandler)
public static AlertBuilder alert(String title)
public AlertBuilder withTitle(String title)
public AlertBuilder withBody(String body)
public AlertBuilder withContent(com.vaadin.ui.Component content)
public AlertBuilder withLevel(com.vaadin.ui.Notification.Type level)
public AlertBuilder withConfirmButtonCaption(String confirmButtonCaption)
public AlertBuilder withOkButtonCaption(String okButtonCaption)
public AlertBuilder withDeclineButtonCaption(String declineButtonCaption)
public AlertBuilder withConfirmationHandler(Runnable confirmationHandler)
public com.vaadin.ui.Window build()
public com.vaadin.ui.Window buildAndOpen()
Copyright © 2021 Magnolia International Ltd.. All rights reserved.