Re: GWT Native Method Warning

46 views
Skip to first unread message

Matthew Dempsky

unread,
Nov 19, 2012, 6:07:57 PM11/19/12
to google-web-toolkit
On Sun, Nov 18, 2012 at 11:16 AM, Patrax <pje...@gmail.com> wrote:
public void callFacebookAPI(String url) {

This is an instance method.
 
    FB.login(function(response) {

[FYI, you should probably wrap your callback in $entry().  See  https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsJSNI#calling]

            @com.google.gwt.smartpark.client.map.SmartPark::callFacebookAPI(Ljava/lang/String;Ljava/lang/
String;)(facebookUrl);         

You're calling the instance method without a receiver object.  You either need to change the instance method into a static method, or add a receiver object like "foo.@[...](facebookUrl);"  See https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsJSNI#methods-fields


Colin Alworth

unread,
Nov 19, 2012, 10:41:36 PM11/19/12
to google-we...@googlegroups.com
In addition to matthew's comment, you are invoking a method that apparently has two arguments
callFacebookAPI(Ljava/lang/String;Ljava/lang/String;)

with only one:
(facebookUrl)

Delete one of the two Ljava/lang/String; parts on the method invocation so you actually point to your method
callFacebookAPI(String url)
correctly.

On Sunday, November 18, 2012 1:16:15 PM UTC-6, Patrax wrote:

I'm doing a project in GWT to deploy in AppEngine and I'm getting a warning in Eclipse saying: JavaScript parsing: Expected an identifier in JSNI reference Any ideas on what's causing this?

public void callFacebookAPI(String url) {
        JsonpRequestBuilder requestBuilder = new JsonpRequestBuilder();
        requestBuilder.requestObject(url, new AsyncCallback<FbUser>() {

            public void onFailure(Throwable caught) {
                System.out.println("FAIL" );
            }

            @Override
            public void onSuccess(FbUser result) {
                facebookUser = result;
                System.out.println("Facebook name:" + facebookUser.getName());
            }

        });     
    }


    private final native void doFbLoginFunction() /*-{


    FB.login(function(response) {
        if (response.authResponse) {
            // connected
            //return response.session;
            var accessToken = response.accessToken;
            var url = "http://graph.facebook.com/me?access_token=";

            var facebookUrl = url + accessToken;
            @com.google.gwt.smartpark.client.map.SmartPark::callFacebookAPI(Ljava/lang/String;Ljava/lang/
String;)(facebookUrl);         

        } else {
Reply all
Reply to author
Forward
0 new messages