问题
I am developing a GWT application to get the query results from the Freebase. This is the code of my EntryPoint class.
package com.google.tracker.client;
import com.freebase.api.Freebase;
import com.freebase.json.JSON;
import com.google.gwt.core.client.EntryPoint;
public class Tracker implements EntryPoint{
public void onModuleLoad() {
Freebase freebase = Freebase.getFreebase();
String query_str = "{" +
"'id': null," +
"'type': '/film/film'," +
"'name': 'Blade Runner'," +
"'directed_by': [{" +
"'id': null," +
"'name': null" +
"}]" +
"}".replace('\'', '"');
JSON query = new JSON(query_str);
JSON result = freebase.mqlread(query);
@SuppressWarnings("unused")
String director = result.get("result").get("directed_by").get(0).get("name").string();
}
}
I am getting following errors :
[ERROR] Line 10: No source code is available for type com.freebase.api.Freebase; did you forget to inherit a required module?
[ERROR] Line 21: No source code is available for type com.freebase.json.JSON; did you forget to inherit a required module?
What could be the possible reasons for these?
回答1:
Freebase's API package is not a GWT module and as such can't be translated to Javascript. That's why there's "No source code available". You need to make the call to Freebase from the server and send the results down to the client.
来源:https://stackoverflow.com/questions/9311438/using-freebase-api-in-java