appUri = getAppUri();
+ // TODO Hardcoded (finnish) id -> change
console = new Console(RootPanel.get("itmtk-loki"));
makeUidlRequest("repaintAll=1");
try {
rb.sendRequest(requestData, new RequestCallback() {
public void onError(Request request, Throwable exception) {
+ // TODO Better reporting to user
console.error("Got error");
}
});
} catch (RequestException e) {
+ // TODO Better reporting to user
console.error(e.getMessage());
}
}
private void handleReceivedJSONMessage(Response response) {
Date start = new Date();
String jsonText = response.getText().substring(3) + "}";
+ // TODO This should be a console message, right?
System.out.println(jsonText);
JSONValue json;
try {
console.log(jsonText);
return;
}
+ // Handle redirect
+ JSONObject redirect = (JSONObject) ((JSONObject) json)
+ .get("redirect");
+ if (redirect != null) {
+ JSONString url = (JSONString)redirect.get("url");
+ if (url!=null) {
+ console.log("redirecting to " + url.stringValue());
+ redirect(url.stringValue());
+ return;
+ }
+ }
+
// Store resources
JSONObject resources = (JSONObject) ((JSONObject) json)
.get("resources");
+ "ms for " + jsonText.length() + " characters of JSON");
}
+
+ // Redirect browser
+ private static native void redirect(String url)/*-{
+ $wnd.location = url;
+ }-*/;
+
public void registerPaintable(String id, Paintable paintable) {
idToPaintable.put(id, paintable);
public boolean updateComponent(Widget component, UIDL uidl,
boolean manageCaption) {
- // Switch to correct implementation if neede
+ // Switch to correct implementation if needed
if (!widgetFactory.isCorrectImplementation(component, uidl)) {
Layout parent = getParentLayout(component);
if (parent != null) {