簡體   English   中英

Vaadin Button操作和帶兩個操作的MessageBox

[英]Vaadin Button action and MessageBox with 2 actions to do

我創建了一個刪除按鈕,可以刪除數據庫中和日歷中的數據。 但是我想使用MessageBox來確保這不是一個錯誤的選擇。 但是我無法在MessageBox.WithYesButton()中添加2個動作,所以您知道我該怎么做嗎? 這是我的代碼:

remove.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                for (CalendaringItem calendaringItem : calendaringList.getCalendarings()) {
                    MessageBox.createQuestion().withMessage("Do you want to delete this event ?").withYesButton(()
                            -> calendaringItem.delete(calendaringItem, name.getValue())).withNoButton().open();
                    //calendar.removeEvent(e);
                }
                window.close();
            }
        });

謝謝您的幫助 !

 MessageBox.createQuestion()
           .withMessage("Do you want to delete this event ?")
           .withYesButton( () -> {
               calendaringItem.delete(calendaringItem, name.getValue());
               //action
               //action2 ...
           })
           .withNoButton().open();

而且,您不必聲明新的ClickListener。 您可以簡單地做到這一點:

remove.addClickListener(event -> {
    actionAfterButtonClick();
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM