How to dismiss Vaadin 8 confirmation dialog while performing lengthy operation

扶醉桌前 提交于 2020-01-06 03:56:31

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!