我确实下载了ConfirmDialog插件。现在,我正在尝试在我的自定义组件中创建一个confirmdialong,但我想这对于这个ui不起作用。
public class Customer extends CustomComponent implements Button.ClickListener{
private Button btnSave;
private VerticalLayout vLayout;
public Customer(){
vLayout = new VerticalLayout();
setCompositionRoot(vLayout);
btnSave = new Button("Save");
btnSave.addClickListener(this);
vLayout.addComponent(btnSave);
}
@Override
public void buttonClick(ClickEvent event) {
if(event.getButton() == btnSave){
save();
}
}
/** save informations if ConfirmDialog return true */
private void save(){
ConfirmDialog.show(this, "Please Confirm:", "Are you really sure?",
"I am", "Not quite", new ConfirmDialog.Listener() {
public void onClose(ConfirmDialog dialog) {
if (dialog.isConfirmed()) {
System.out.println(dialog.isConfirmed());
} else {
System.out.println(dialog.isConfirmed()); }
}
});
}
}
当我创建ConfirmDialog并将我的CustomComponent传递为Ui时(此)不接受。我尝试传递null,但也不起作用。
答案 0 :(得分:1)
/** save informations if ConfirmDialog return true */
private void save(){
ConfirmDialog.show(UI.getCurrent(), "Please Confirm:", "Are you really sure?",
"I am", "Not quite", new ConfirmDialog.Listener() {
public void onClose(ConfirmDialog dialog) {
if (dialog.isConfirmed()) {
System.out.println(dialog.isConfirmed());
} else {
System.out.println(dialog.isConfirmed()); }
}
});
}