GWT Javascript Exception in Hosted Mode: The result of the expression 'doc.getBoxObjectFor' [undefined] is not a function

Has anyone seen this exception? I work in host mode on GWT 1.6.4 on a Mac. I use AutoSuggest and it throws this exception while trying to show a popup. It works fine in compiled mode, but obviously the placement mode is pretty important.

[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError): Result of expression 'doc.getBoxObjectFor' [undefined] is not a function.
 line: 71
 sourceId: 1152617088
 sourceURL: jar:file:/Users/holmes/.m2/repository/com/google/gwt/gwt-user/1.6.4/gwt-user-1.6.4.jar!/com/google/gwt/dom/client/DOMImplMozillaOld.java
 expressionBeginOffset: 288
 expressionCaretOffset: 307
 expressionEndOffset: 313
    at com.google.gwt.dom.client.DOMImplMozillaOld.getAbsoluteLeftImpl(Native Method)
    at com.google.gwt.dom.client.DOMImplMozillaOld.getAbsoluteLeft(DOMImplMozillaOld.java:29)
    at com.google.gwt.dom.client.Element$.getAbsoluteLeft$(Element.java:86)
    at com.google.gwt.user.client.DOM.getAbsoluteLeft(DOM.java:646)
    at com.google.gwt.user.client.ui.UIObject.getAbsoluteLeft(UIObject.java:487)
    at com.google.gwt.user.client.ui.PopupPanel.position(PopupPanel.java:1015)
    at com.google.gwt.user.client.ui.PopupPanel.access$5(PopupPanel.java:958)
    at com.google.gwt.user.client.ui.PopupPanel$1.setPosition(PopupPanel.java:811)
    at com.google.gwt.user.client.ui.PopupPanel.setPopupPositionAndShow(PopupPanel.java:700)
    at com.google.gwt.user.client.ui.PopupPanel.showRelativeTo(PopupPanel.java:809)
    at com.google.gwt.user.client.ui.SuggestBox.showSuggestions(SuggestBox.java:768)
    at com.google.gwt.user.client.ui.SuggestBox.access$3(SuggestBox.java:738)
    at com.google.gwt.user.client.ui.SuggestBox$1.onSuggestionsReady(SuggestBox.java:281)
    at com.google.gwt.user.client.ui.MultiWordSuggestOracle.requestSuggestions(MultiWordSuggestOracle.java:225)
    at com.google.gwt.user.client.ui.SuggestBox.showSuggestions(SuggestBox.java:640)
    at com.google.gwt.user.client.ui.SuggestBox.refreshSuggestions(SuggestBox.java:713)
    at com.google.gwt.user.client.ui.SuggestBox.access$6(SuggestBox.java:705)
    at com.google.gwt.user.client.ui.SuggestBox$1TextBoxEvents.onKeyUp(SuggestBox.java:678)
    at com.google.gwt.event.dom.client.KeyUpEvent.dispatch(KeyUpEvent.java:54)
    at com.google.gwt.event.dom.client.KeyUpEvent.dispatch(KeyUpEvent.java:1)
    at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
    at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:52)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:90)
    at com.google.gwt.user.client.ui.TextBoxBase.onBrowserEvent(TextBoxBase.java:193)
    at com.google.gwt.user.client.ui.Composite.onBrowserEvent(Composite.java:54)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1320)
    at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1299)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262)
+3
source share
4 answers

Firefox 3.7a1pre ( "Minefield" ) . getBoxObjectFor getBoundingClientRect. , GWT. - , .

private static native void firefox3compatibility() /*-{
 if (!$doc.getBoxObjectFor) {
  $doc.getBoxObjectFor = function (element) {
   var box = element.getBoundingClientRect();
   return { "x"      : box.left,  "y"       : box.top,
            "screenX": box.left,  "screenY" : box.top,
            "width"  : box.width, "height"  : box.height };
  }
 }
}-*/;
+3

, screenX screenY :

private static native void firefox3compatibility() /-{ if (!$doc.getBoxObjectFor) { $doc.getBoxObjectFor = function (element) { var box = element.getBoundingClientRect(); return { "x" : box.left, "y" : box.top, "width" : box.width, "height" : box.height, "screenX": box.left, "screenY":box.top }; } } }-/;

0

nitobi.browser.detect(); nitobi.toolkit.js. 575. (ish)

if(nitobi.browser.MOZ) {
    if(typeof document.getBoxObjectFor == "undefined") {
        document.getBoxObjectFor = function(elem) {
            var obj = new Object;
            var rect = elem.getBoundingClientRect();
            obj.y = rect.top;
            obj.x = rect.left;
            obj.width =Math.abs(rect.right-rect.left);
            obj.height = Math.abs(rect.bottom-rect.top);
            return obj;
        }
    }
}

, Gecko, , getBoundingClientRect, ​​ Mozilla.

They are deprecated by getBoxObjectFor and instead added this function.

Hope this helps.

0
source

getBoxObjectFordeprecated for FF3.6. Here is the problem that solves this problem in GWT: Problem 4605

0
source

Source: https://habr.com/ru/post/1710860/


All Articles