如何在执行冗长操作时关闭 Vaadin 8 确认对话框

How to dismiss Vaadin 8 confirmation dialog while performing lengthy operation

我有 Vaadin 8 确认码,它执行一项长期任务。我想关闭对话框并显示进度条:-

        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);
                        }
                    }
                });

我想在用户 select 同意后立即关闭此对话框。我想显示一个不确定的进度条。我做不到。怎么做?请让我知道我该怎么做?

这是常见问题解答,您需要使用 Server Push 并在后台线程中更新进度条。这里有一个博客 post 和关于它的视频

https://vaadin.com/blog/community-answer-processing-a-file-in-a-background-thread

这里对这个话题也有很好的讨论

Update Vaadin Progressbar with push asynchronously

And I would like to show an Indeterminate progress bar.

这意味着您可以稍微简化一些事情。如果你不想在运行过程中更新进度条,你只需要将进度条置于UI Indeterminate mode 完成后,再次更新UI。