Thursday, September 25, 2014

Re: I need help calling GWT code from Javascript passing in generic arguments and/or callbacks -- URGENT

Thank you! Helped me a lot!

On Tuesday, March 6, 2012 5:53:25 AM UTC+1, babakm wrote:
I built an API in GWT for accessing a series of complex services. I
wanted to do tons of client side processing and I chose GWT (been
doing GWT for years now). However, my users will be using Javascript.
I can easily call GWT from Javascript. No problem. I set up a routine
I run as soon as my EntryPoint is invoked, and it runs some Javascript
(just as explained in GWT docs). The problem is that many (more like
ALL) of my objects and methods use callbacks (everything is async).
And in many cases, they take Java generics (good old C++ style
templates). For instance:

public static void getConnection(final Callback<Connection> callback)
{
        Connection.get(callback);
}

I want to register this method using:

public static native void exportStaticMethod() /*-{
        $wnd.computeLoanInterest =
$entry(@com.mhsystems.rsmapiproxy.client.SomeTestClass::computeLoanInterest(IFI));
        $wnd.getConnection =
$entry(@com.mhsystems.rsmapiproxy.client.SomeTestClass::getConnection(Lcom/
mhsystems/rsmapiproxy/api/Callback));
}-*/;

How do I do that? The first one (computeLoanInterest) works. The
second one, getConnection, does not. Callback<T> is an interface (not
an object). Could that be the problem? I don't know how to declare the
generic Connection here. If that is not possible, I can write specific
objects but at the end of the day, I need the Javascript code to pass
in a Javascript callback that is called by the GWT code when it is all
said and done.

Cheerz!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment