Hi Thomas,
I had stumbled upon this solution. However, you have an additional detail I
don't understand: The split between
interface MyModelObject
and
class MyModelObjectImpl extends JavaScriptObject implements MyModelObject
What advantage does this gain? I think it has something to do w/. DI or
testing, but I cannot see why one wouldn't do
void get(AsyncCallback<MyModelObjectImpl> callback);
i.e. don't use an interface, just do all templating via the class? Also, I
see you're using @ImplementedBy. How does this differ from
bind(new TypeLiteral<SessionReaderTxn<Session>>()
{}).to(MockSessionReader.class);
There is a redundancy in the above that I haven't figured out how to factor
out. Ideally, it should be either
bind(new TypeLiteral<ReaderTxn<Session>>() {}).to(MockSessionReader.class);
or
bind(new TypeLiteral<SessionTxn<Reader>>() {}).to(MockSessionReader.class);
Cheers,
jec
On Fri, Nov 27, 2009 at 2:30 PM, Thomas Broyer <[email protected]> wrote:
>
>
> On 27 nov, 16:56, Jeff Chimene <[email protected]> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.