【问题标题】:GWT Window.confirm() triggered by onchange of ValueListBox crashing Safari on iPad iOS 7.0.6GWT Window.confirm() 由 ValueListBox 的 onchange 触发,导致 iPad iOS 7.0.6 上的 Safari 崩溃
【发布时间】:2014-03-01 16:10:22
【问题描述】:

我最近收到了一张支持票,说我们的一些网络应用程序的功能在 iPad 上导致 safari 崩溃。在最新的 iOS 7.0.6 更新之前,此功能没有问题。我们有一些 GWT ValueListBoxes,当它们的值改变时会改变 DOM。在进行更改之前,我们向用户显示 Window.confirm() 消息,告知他们更改将产生的影响,并询问他们是否仍想继续。自更新以来,确认选项无任何作用,Safari 崩溃。这只发生在 iPad 上。该功能在桌面浏览器(IE、Chrome、Firefox、Safari 和 Chrome 移动模拟器)上运行良好,但在 iPad 上会导致 safari 崩溃。其他人有这个问题吗?

这是崩溃的截图:

下面是代码示例:

this._view.isPrimaryFoodGen().addValueChangeHandler(new ValueChangeHandler<Boolean>()
{
    @Override
    public void onValueChange(final ValueChangeEvent<Boolean> event)
    {
        @SuppressWarnings("unchecked")
        ValueListBoxWithOldValue<Boolean> vlb = (ValueListBoxWithOldValue<Boolean>)event.getSource();

        if (confirmQuestionChange() ){
            changeGroupAndQuestions(CONSTANTS.PRIMARY_FOOD, event.getValue());
        }
        else {
            vlb.setValue(vlb.getOldValue());
        }
    }
});

public boolean confirmQuestionChange()
{
    if (!this._view.isImageCriteriaQuestionsVisible())
    { //questions aren't currently visible
        return true;
    }

    boolean confirmed = Window.confirm("Changing this response will delete image data already collected. Do you wish to proceed?");
    return confirmed;
}

任何有关防止 iPad 崩溃的解决方案的帮助将不胜感激。在调用 Window.confirm() 之前,我曾尝试关注另一个元素,希望删除覆盖层和 ValueListBox 选项以阻止任何 JS 冲突,但它没有奏效。

在下一次更新解决此问题之前,我是否会任由 Apple 摆布? 或者有没有可行的解决方案?

【问题讨论】:

    标签: ios ipad gwt safari


    【解决方案1】:

    好的,所以事实证明,由于我找不到继续使用 Window.confirm() 的修复程序,我必须通过更改 onValueChange() 和 confirmQuestionChange() 方法来使用手动创建的 DialogBox 来实现解决方案而不是 Window.confirm()。这不是最佳解决方案,但 Safari 不会再在 iPad 上崩溃,用户可以完成他们的工作。以下是代码更改:

        this._view.isPrimaryFoodGen().addValueChangeHandler(new ValueChangeHandler<Boolean>()
    {
        @Override
        public void onValueChange(final ValueChangeEvent<Boolean> event)
        {
            confirmQuestionChange(CONSTANTS.PRIMARY_FOOD, event);
        }
    
    });
    
    public void confirmQuestionChange(final String question, ValueChangeEvent<Boolean> event)
    {
        final ValueListBoxWithOldValue<Boolean> vlb = (ValueListBoxWithOldValue<Boolean>)event.getSource();
    
        if (!this._view.isImageCriteriaQuestionsVisible())  //questions aren't currently visible, can change them no problem
        { 
            changeGroupAndQuestions(question, vlb.getValue());
        }
        else{
          //the following fix was put in place for issues with Safari on the iPad OPS-76
            final DialogBox dialogBox = new DialogBox();
            dialogBox.setHTML("<center>Changing this response will delete<br />image data already collected.<br />Do you wish to proceed?</center>");
            dialogBox.setAnimationEnabled(true);
            Button yesButton =  new Button("YES");
            Button noButton = new Button("NO");
            HorizontalPanel dialogHPanel = new HorizontalPanel();
            dialogHPanel.setWidth("100%");
            dialogHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
            dialogHPanel.add(noButton);
            dialogHPanel.add(yesButton);
    
            noButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    vlb.setValue(vlb.getOldValue());
                    dialogBox.hide();
                  }
            });
    
            yesButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    changeGroupAndQuestions(question, vlb.getValue());
                    dialogBox.hide();
                  }
            });
    
            // Set the contents of the Widget
            dialogBox.setWidget(dialogHPanel);
            dialogBox.setPopupPosition(180, 425);
            dialogBox.show();
        }
    }
    

    这是一个屏幕截图:

    如您所见,ValueListBox 选项在 DialogBox 出现之前关闭,屏幕不再锁定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-24
      • 1970-01-01
      • 2015-06-10
      • 2020-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多