Sunday, May 8, 2016

Re: Returning String From JSNI method

Because your request is asynchron and your JSNI code does not wait at the $wnd.$.get call. Your method will complete immediately and return nothing as it does not have a return statement.

You would need to change your getData() method to something like:

public native void getData(String trainerName, Callback callback)/*-{
 $wnd.$.get( "
http://testdastuff.dev/trainerstats", { trainer: trainerName} )
 .fail(function() {
    callback.@com.example.Callback::onFail()();
 })
 .done(function( data ) {
    callback.@com.example.Callback::onSuccess(Ljava/lang/String;)(data);
 });

 }-*/
;


-- J.

--
You received this message because you are subscribed to the Google Groups "GWT Users" 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 https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment