aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2007-06-07 12:34:50 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2007-06-07 12:34:50 +0000
commit078e4ae7b1a56ccb5ea71e3e3d68e0f7eeb0ef3a (patch)
tree9468231b96f7646cbecdbd5a227ffd0185b0368d /src
parent410c61d0433f836fb98badce26f8bf681fc4a1df (diff)
downloadvaadin-framework-078e4ae7b1a56ccb5ea71e3e3d68e0f7eeb0ef3a.tar.gz
vaadin-framework-078e4ae7b1a56ccb5ea71e3e3d68e0f7eeb0ef3a.zip
Client now renderes unknown compoenents with special component that dirs their uidl, instead of crashing
svn changeset:1637/svn branch:trunk
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/itmill/toolkit/terminal/gwt/client/Client.java73
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetFactory.java3
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/UnknownComponent.java32
3 files changed, 74 insertions, 34 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Client.java b/src/com/itmill/toolkit/terminal/gwt/client/Client.java
index 0068b67e57..2c1f0b4303 100755
--- a/src/com/itmill/toolkit/terminal/gwt/client/Client.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/Client.java
@@ -102,43 +102,50 @@ public class Client implements EntryPoint {
private void handleReceivedJSONMessage(Response response) {
Date start = new Date();
- JSONValue json = JSONParser
- .parse(response.getText().substring(3) + "}");
-
- // Process changes
- JSONArray changes = (JSONArray) ((JSONObject) json).get("changes");
- for (int i = 0; i < changes.size(); i++) {
- try {
- UIDL change = new UIDL((JSONArray) changes.get(i));
- console.log("Received the following change: ");
+
+ try{
+ JSONValue json = JSONParser
+ .parse(response.getText().substring(3) + "}");
+ // Process changes
+ JSONArray changes = (JSONArray) ((JSONObject) json).get("changes");
+ for (int i = 0; i < changes.size(); i++) {
try {
- console.dirUIDL(change);
- } catch (Exception e) {
- // TODO: dir doesn't work in any browser although it should work (works in hosted mode)
- // it partially did at some part but now broken.
- }
- UIDL uidl = change.getChildUIDL(0);
- Paintable paintable = getPaintable(uidl.getId());
- if (paintable != null)
- paintable.updateFromUIDL(uidl, this);
- else {
- if (!uidl.getTag().equals("window"))
- throw new IllegalStateException("Received update for "
- + uidl.getTag()
- + ", but there is no such paintable ("
- + uidl.getId() + ") registered yet.");
- Widget window = createWidgetFromUIDL(uidl);
- // We should also handle other windows
- RootPanel.get("itmtk-ajax-window").add(window);
+ UIDL change = new UIDL((JSONArray) changes.get(i));
+ console.log("Received the following change: ");
+ try {
+ console.dirUIDL(change);
+ } catch (Exception e) {
+ // TODO: dir doesn't work in any browser although it should work (works in hosted mode)
+ // it partially did at some part but now broken.
+ }
+ UIDL uidl = change.getChildUIDL(0);
+ Paintable paintable = getPaintable(uidl.getId());
+ if (paintable != null)
+ paintable.updateFromUIDL(uidl, this);
+ else {
+ if (!uidl.getTag().equals("window"))
+ throw new IllegalStateException("Received update for "
+ + uidl.getTag()
+ + ", but there is no such paintable ("
+ + uidl.getId() + ") registered yet.");
+ Widget window = createWidgetFromUIDL(uidl);
+ // We should also handle other windows
+ RootPanel.get("itmtk-ajax-window").add(window);
+ }
+
+ } catch (Throwable e) {
+ e.printStackTrace();
}
-
- } catch (Throwable e) {
- e.printStackTrace();
+
}
-
+ long prosessingTime = (new Date().getTime()) - start.getTime();
+ console.log(" Processing time was " + String.valueOf(prosessingTime));
+ } catch (Exception e) {
+ // TODO: remove this try catch when uidl JSON stabilizes
+ console.log("Error parsing JSON:");
+ console.log(response.getText().substring(3) + "}");
}
- long prosessingTime = (new Date().getTime()) - start.getTime();
- console.log(" Processing time was " + String.valueOf(prosessingTime));
+
}
public void registerPaintable(String id, Paintable paintable) {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetFactory.java b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetFactory.java
index 03fae65441..3d144da418 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetFactory.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetFactory.java
@@ -5,6 +5,7 @@ import com.itmill.toolkit.terminal.gwt.client.ui.Button;
import com.itmill.toolkit.terminal.gwt.client.ui.GridLayout;
import com.itmill.toolkit.terminal.gwt.client.ui.Label;
import com.itmill.toolkit.terminal.gwt.client.ui.OrderedLayout;
+import com.itmill.toolkit.terminal.gwt.client.ui.UnknownComponent;
import com.itmill.toolkit.terminal.gwt.client.ui.Window;
public class DefaultWidgetFactory implements WidgetFactory {
@@ -22,7 +23,7 @@ public class DefaultWidgetFactory implements WidgetFactory {
if ("gridlayout".equals(tag))
return new GridLayout();
- return null;
+ return new UnknownComponent();
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/UnknownComponent.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/UnknownComponent.java
new file mode 100644
index 0000000000..b5efa79116
--- /dev/null
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/UnknownComponent.java
@@ -0,0 +1,32 @@
+package com.itmill.toolkit.terminal.gwt.client.ui;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Tree;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.UIDL;
+
+public class UnknownComponent extends Composite implements Paintable{
+
+ com.google.gwt.user.client.ui.Label caption = new com.google.gwt.user.client.ui.Label();;
+ Tree uidlTree = new Tree();
+
+ public UnknownComponent() {
+ VerticalPanel panel = new VerticalPanel();
+ panel.add(caption);
+ panel.add(uidlTree);
+ initWidget(panel);
+ setStyleName("itmtk-unknown");
+ caption.setStyleName("itmtk-unknown-caption");
+ }
+
+ public void updateFromUIDL(UIDL uidl, Client client) {
+ setCaption("Client faced an unknown component type. Unrendered UIDL:");
+ uidlTree.addItem(uidl.dir());
+ }
+
+ public void setCaption(String c) {
+ caption.setText(c);
+ }
+}