我正在GWT中做一个要在AppEngine中部署的项目,并且在Eclipse中收到一条警告说:
JavaScript解析:JSNI中应为标识符
 参考
关于什么原因的任何想法?

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 {
            // cancelled
        }
    });

最佳答案

callFacebookAPI不是静态的,因此JSNI引用中的@之前必须有一些内容,例如

var that = this;
$wnd.FB.login($entry(function(response) {
   // ...
   [email protected]::callFacebookAPI(Ljava/lang/String;)(facebookUrl);
   // ...
}));


另外,您的callFacebookAPI采用单个参数,因此JSNI签名应具有单个Ljava/lang/String;

10-08 03:57