I am trying to use MessageBox vaadin addon on my application but I can’t find out which variable to test if user clicked on “Yes” or if clicked on “No” on a question Dialog.
Like in this code below. How do I continue from there to take actions when user click on yes or no.
MessageBox mb = new MessageBox(HausOverview.this.getWindow(),
“Are you sure?”,
MessageBox.Icon.QUESTION,
“Do you really want to continue?”,
new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, “Yes”),
new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, “No”));
mb.show();
});
btnTest.addListener(new Button.ClickListener() { @Override
public void buttonClick(ClickEvent event) {
MessageBox mb = new MessageBox(mainWindow.getWindow(),
“Are you sure?”,
MessageBox.Icon.QUESTION,
“Do you really want to continue?”,
new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, “Yes”),
new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, “No”));
mb.show(new MessageBox.EventListener() {
@Override
public void buttonClicked(ButtonType buttonType) {
System.out.println("This button was pressed: " + buttonType);
if (buttonType.toString() == "YES") {
mainWindow.showNotification("This button was pressed: " + buttonType);
} else {
mainWindow.showNotification("This button was pressed: " + buttonType);
}
}
});
}
});