0
我想將ConfirmDialog的標題「確認」更改爲我的語言。我看着this,但代碼對我來說沒有意義,因爲我的vaadin插件中的show方法是一種靜態方法,而且似乎無法顯示工廠返回的對話框。Vaadin ConfirmDialog更改標題
我用這個代碼來包裝對話框:
package com.xxx.dialog;
import org.vaadin.dialogs.ConfirmDialog;
import com.xxx.message.MessageByLocaleService;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
public class DeleteDialog {
private ConfirmDialog cd;
public DeleteDialog(MessageByLocaleService messageByLocaleService) {
cd = ConfirmDialog.getFactory()
.create(messageByLocaleService.getMessage("caption.confirm"),
"", "OK", "Cancel", "");
}
public abstract static class MyListener {
public abstract void receive();
}
public void show(UI ui, MessageByLocaleService messageByLocaleService, MyListener yes, MyListener cancel) {
//this.setCaption(messageByLocaleService.getMessage("caption.confirm"));
//this.setMessageLabel(new Label(messageByLocaleService.getMessage("caption.confirm")));
cd.show(ui, messageByLocaleService.getMessage("confirm.delete"),
new ConfirmDialog.Listener() {
private static final long serialVersionUID = 1L;
public void onClose(ConfirmDialog dialog) {
if (dialog.isConfirmed()) {
// Confirmed to continue
yes.receive();
} else {
// User did not confirm
cancel.receive();
}
}
});
}
}
我有這個class DeleteDialog
爲extends ConfirmDialog
了一段時間,這就是爲什麼一些我的企圖被註釋掉沒有意義的。
您是否檢查messageByLocaleService.getMessage(「caption.confirm」)是否返回null? – nyg
它不應該爲空,翻譯是在翻譯文件中。問題是'show'是一個靜態方法,我需要一個類方法。也許我會將插件版本降級爲具有非靜態方法的版本。 – Adder