问题
I have Vaadin 8 confirmation code there it performs a long lasting task. I would like to dismiss the dialog and show a progress bar:-
ConfirmDialog.show(UI.getCurrent(), "Dynamic Report warning caption",
"More than " +rows+ " rows in this table. It will take long time to generate this report.\nDo you still want to continue? ",
SalkkuTM.getI18N("PortfolioManagementMenuBar.deleteData.confirmDialog.yes.caption"),
SalkkuTM.getI18N("PortfolioManagementMenuBar.deleteData.confirmDialog.no.caption"), new ConfirmDialog.Listener() {
public void onClose(ConfirmDialog dialog) {
ProgressBar bar = new ProgressBar();
bar.setIndeterminate(true);
if (dialog.isConfirmed()) {
layout.addComponent(bar);
// this method does a long lasting task.
dynamicReportParameterGenerator();
bar.setVisible(false);
}
}
});
I would like to dismiss this dialog as soon as user select yes. And I would like to show an Indeterminate progress bar. I couldn't manage it. How to do it? Please let me know how can I do it?
回答1:
This is FAQ stuff, you need to use Server Push and update progress bar in background thread. There is a blog post and video about it here
https://vaadin.com/blog/community-answer-processing-a-file-in-a-background-thread
There is a good discussion about the topic here too
Update Vaadin Progressbar with push asynchronously
And I would like to show an Indeterminate progress bar.
This means that you can simplify things a little. If you do not want to update progress bar during the operation, you just need to put progress bar in UI in Indeterminate mode and once complete, update the UI again.
来源:https://stackoverflow.com/questions/50999262/how-to-dismiss-vaadin-8-confirmation-dialog-while-performing-lengthy-operation