How to prevent DoubleSubmit in a GWT application?

后端 未结 2 1070
我在风中等你
我在风中等你 2021-01-05 19:16

To clarify what double submit is: When the user clicks on a submit button twice, the server will process the same POST data twice. To avoid this (apart from disabling the bu

2条回答
  •  囚心锁ツ
    2021-01-05 19:29

    This will be helpfull for you -

        final Button btn = new Button("Open");
        btn.addSelectionListener(new SelectionListener() {
            @Override
            public void componentSelected(ButtonEvent ce) {
    
                        btn.setEnabled(false);
    
                        openMethod(name, new AsyncCallback() {
    
                            public void onFailure(Throwable caught) {
                                    btn.setEnabled(true);
                        }
                        public void onSuccess(Void result) {
                            MessageBox.alert(info, "Opened Window", null);
                            btn.setEnabled(true);
                            window.hide();
                        }
                    });
            }
        });
    

提交回复
热议问题