Saturday, November 28, 2009

Re: JSON - When to use JSONParser and when JavaScript object

Thanks, very nice. I'll give it a try.

On Fri, Nov 27, 2009 at 2:30 PM, Thomas Broyer <t.broyer@gmail.com> wrote:


On 27 nov, 16:56, Jeff Chimene <jchim...@gmail.com> wrote:
> On 11/12/2009 12:45 PM, Thomas Broyer wrote:
>
> > And actually, now that I've switched to GWT 2.0, I use interfaces to
> > model my objects, with RemoteService/*Async interfaces to model my
> > services; and I implement them using JSOs (JSOs can implement
> > interfaces under certain conditions in GWT 2.0)
>
> Hi Thomas,
>
> Would you mind expanding on this a little bit? How does one implement a
> JSO interface?

interface MyModelObject {
  String getFoo();
  void setFoo(String foo);
}

class MyModelObjectImpl extends JavaScriptObject implements
MyModelObject {
  protected MyModelObjectImpl() { }
  public final native String getFoo() /*-{ return this.foo; }-*/;
  public final native void setFoo(String foo) /*-{ this.foo = foo; }-
*/;
}

There's really nothing special, but the interface cannot be
implemented by more than one JSO.

I then do:
interface MyService extends RemoteService {
  MyModelObject get();
}
@ImplementedBy(MyServiceAsyncImpl.class)
interface MyServiceAsync {
 void get(AsyncCallback<MyModelObject> callback);
}

implemented as:
class MyServiceAsyncImpl implements MyServiceAsync {
  public void get(AsyncCallback<MyModelObject> callback) {
     // create a RequestBuilder, and in the
RequestCallback::onResponceReceived, parse the response
(JsonUtils.unsafeEval for instance) into a MyModelObjectImpl and pass
it to the callback.onSuccess()
  }
}

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate