java - Vaadin addSucceededListener
问题描述
我在 Vaadin 8 中有一个上传按钮,上面有一个 addSucceededListener 侦听器 - 关于它我不知道很多事情......而且我找不到这种类型的侦听器的太多信息。当我单击该按钮时,我想启动一个确认窗口 - 我用它实例化ConfirmButton cd = new ConfirmButton("Confirmare");
并打开模式弹出窗口cd.openInModalPopup();
。
我的问题是弹出窗口->cd.openInModalPopup();
仅在“选择文件”窗口打开后才显示,我必须选择一个文件。我的问题是如何先显示确认信息,并且只有在用户确认后,才打开“选择文件”窗口。
添加以下代码:
<vaadin-upload button-caption="Incarc INDICATORI " _id="cmdIncarcRaportInd" :right></vaadin-upload>
public Upload getCmdIncarcRaportInd() {
return cmdIncarcRaportInd;
}
getCmdIncarcRaportInd().addSucceededListener(event -> {
int NR_Raport=0;
String WBL ="";
WBL = getCheBL().getValue()?"B":"I";
if(raport!=null) NR_Raport=Numeric.getValInt(raport.get("Nr. Raport"));
if (NR_Raport==0) {
Notification notif = new Notification("Atentie",
"NR Raport incorect",
Notification.Type.ERROR_MESSAGE);
notif.setDelayMsec(-1);
notif.show(Page.getCurrent());
return;
}
int NR_RaportW = NR_Raport;
if(WBL.equals("B")) {
NR_RaportW=99;
ConfirmButton cd = new ConfirmButton("Confirmare");
cd.misWinTitle = "Atentie MIS";
cd.misWinText = "Incarcati valori Base Line ? Daca exista deja, cele vechi se vor rescrie cu valorile noi. CONFIRMATI BASE LINE (DA / NU) ?";
cd.misButOK = "DA";
cd.misButCancel = "NU";
cd.setOkAction(()->{
String raspuns="ok";
if(!receiver.getFile().getName().split("_")[0].equals(proiect.get("Prj cod"))) {
Notification notif = new Notification("Atentie", "Cod Proiect Incorect",
Notification.Type.ERROR_MESSAGE);
notif.setDelayMsec(-1);
notif.show(Page.getCurrent());
return;
}
try {
raspuns = Utility.getSomeData(receiver.getFile(), proiect, 99, themeDisplay);
} catch (IOException | SQLException e) {
raspuns=e.getMessage();
}
Notification notificare = new Notification("Atentie - Incarcare Base Line Indicatori",
raspuns,
Notification.Type.ERROR_MESSAGE);
notificare.setDelayMsec(-1);
notificare.show(Page.getCurrent());
incarcGrdIndicatori(prj_cod);
receiver.uploadFinished(event);
});
cd.setCancelAction(()->{
});
cd.openInModalPopup();
} else {
String raspuns="ok";
if(!receiver.getFile().getName().split("_")[0].equals(proiect.get("Prj cod"))) {
Notification notif = new Notification("Atentie", "Cod Proiect Incorect",
Notification.Type.ERROR_MESSAGE);
notif.setDelayMsec(-1);
notif.show(Page.getCurrent());
return;
}
try {
raspuns = Utility.DoSomeStuff(receiver.getFile(), proiect, NR_RaportW, themeDisplay);
} catch (IOException | SQLException e) {
raspuns=e.getMessage();
}
Notification notificare = new Notification("Atentie - Incarcare Rap Indicatori",
raspuns,
Notification.Type.ERROR_MESSAGE);
notificare.setDelayMsec(-1);
notificare.show(Page.getCurrent());
incarcGrdIndicatori(prj_cod);
receiver.uploadFinished(event);
}
});
//);
}
解决方案
添加一个用户点击的普通按钮,然后只有在满足您的条件时才显示上传按钮?
推荐阅读
- plsqldeveloper - 如何允许同时连接到不同的数据库
- perl - 除非明确包含,否则阻止包含 Perl 模块
- html - 如何使用reactjs更改文件输入的默认文本?
- powershell - 如果键不存在,如何使哈希表抛出错误?
- php - 如何使用 PHP 从 JwPlayer API 获取视频的 URL?
- php - 如果第二个值超过当前时间,则两个值之间的时间差
- git - Github 在问题页面中显示压缩的提交哈希
- c - 在运行时在 c 中创建一系列结构
- reactjs - setState 设置的变量在键盘处理程序事件中不可见
- bash - 有没有办法找到在特定时间创建的所有文件?