Updated Information on JsonpRequestBuilder and Javascript Overlay objects

44 views
Skip to first unread message

Christopher Piggott

unread,
May 7, 2012, 2:51:13 PM5/7/12
to google-we...@googlegroups.com
Hi,

What's the current state of javascript overlay objects and JsonpRequestBuilder?  Should the same code work both in deployed (running on a web server) as well as  debug / development mode?

I'm running into issues with runtime exceptions, and the whole thing is a bit murky to me.  The jsonp "object" that I'm returning is actually nested:

public class SensorList extends JavaScriptObject {
    protected SensorList() { }
    public final native List<Sensor> getSensorList() /*-{ return this.sensorList; } -*/
}

public class Sensor extends JavaScriptObject {
    protected Sensor() { }
    public final native List<Sensor> getSensorName() /*-{ return this.sensorName; } -*/
    /* other properties ... */
}

I just can't seem to make this work with:

builder.requestObject(url,
new AsyncCallback<SensorList>() {
                                    public void onSuccess(SensorList sList) { ... }
}

I either get the no such method <init> problem or if I try to fix that by adding interfaces I get class cast exceptions.

Very confusing.

--Chris


Paul Stockley

unread,
May 7, 2012, 8:52:10 PM5/7/12
to google-we...@googlegroups.com
What kind of type is List? Typically JSO's only support JsArray<> for arrays of JSO's

Christopher Piggott

unread,
May 8, 2012, 9:02:56 AM5/8/12
to google-we...@googlegroups.com

I defined it on the client side as just a List<Sensor> ... maybe that's the problem?  I'll try it.

Peter Donald

unread,
May 7, 2012, 7:57:36 PM5/7/12
to google-we...@googlegroups.com
Hi,

On Tue, May 8, 2012 at 4:51 AM, Christopher Piggott <cpig...@gmail.com> wrote:
> What's the current state of javascript overlay objects and
> JsonpRequestBuilder?  Should the same code work both in deployed (running on
> a web server) as well as  debug / development mode?
>
> I'm running into issues with runtime exceptions, and the whole thing is a
> bit murky to me.  The jsonp "object" that I'm returning is actually nested:
>
> public class SensorList extends JavaScriptObject {
>     protected SensorList() { }
>     public final native List<Sensor> getSensorList() /*-{ return
> this.sensorList; } -*/
> }
>
> public class Sensor extends JavaScriptObject {
>     protected Sensor() { }
>     public final native List<Sensor> getSensorName() /*-{ return
> this.sensorName; } -*/
>     /* other properties ... */
> }

The above code is not expected to work. In particular the use of List
as a return type from a native method is probably not what you want.
You probably want one of

com.google.gwt.core.client.JsArrayString
com.google.gwt.core.client.JsArrayInteger
com.google.gwt.core.client.JsArray<E>

HTH,

Peter Donald
Reply all
Reply to author
Forward
0 new messages