GWT:ClosingEvent setMessage有效,但消息未显示

问题描述 投票:0回答:1

我使用Window.ClosingHandler在用户按下f5或想要关闭选项卡时显示确认对话框。显示对话框,但我的消息被忽略,浏览器(Chrome)向我显示默认消息“您所做的更改可能不会保存。”其他浏览器也会向我显示默认消息,而不是我的消息。

Window.ClosingHandler() {
    @Override
    public void onWindowClosing(Window.ClosingEvent event) {
        event.setMessage("custom message");
    }
});

如何显示我的“自定义消息”?

java gwt
1个回答
0
投票

为事件设置消息将不起作用。它只会显示您所说的默认消息。我认为您应该使用Window.confirm设置自定义消息,例如:

Window.ClosingHandler() {
    @Override
    public void onWindowClosing(Window.ClosingEvent event) {
        if (Window.confirm("custom message")) {
            // stuff if confirmed
        } else {
            // stuff not confirmed
        }
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.