tags:

views:

2630

answers:

3

Anyone ever seen this exception? I'm running in hosted mode on GWT 1.6.4 on a mac. I'm using the AutoSuggest and it's throwing this exception trying to show the popup. It works fine in compiled mode, but obviously hosted mode is rather 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)
+2  A: 

I had a similar problem when using Firefox 3.7a1pre ("Minefield") in compiled mode. Function getBoxObjectFor was replaced by getBoundingClientRect. Here my workaround to get GWT working again. Just call the following method somewhere at the beginning, at least for me it does work.

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 };
  }
 }
}-*/;
Coolcat
thank you thank you thank you!
DenNukem
A: 

This is a great fix, but I also needed to add the screenX, and screenY to the returned object:

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 }; } } }-/;

thaBongo
A: 

I fixed this successfully with the following inserted after nitobi.browser.detect(); in the nitobi.toolkit.js file. It's around line 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;
        }
    }
}

It works well if the Gecko browser you're targeting is implementing the function getBoundingClientRect like Mozilla.

They deprecated getBoxObjectFor, and instead added this function.

Hope that helps.

msumme