From 07c94092bd066846d20e5bf6c4fe87b88f5cd9f2 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 13 Mar 2012 20:40:27 +0200 Subject: [PATCH] #8504 Support passing Connector references to/from client --- .../terminal/gwt/client/communication/JsonDecoder.java | 8 ++++---- src/com/vaadin/terminal/gwt/server/JsonCodec.java | 2 ++ src/com/vaadin/ui/Component.java | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java b/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java index 0eaa106b43..33a415a91d 100644 --- a/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java +++ b/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java @@ -15,8 +15,8 @@ import com.google.gwt.json.client.JSONArray; import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONString; import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.ConnectorMap; +import com.vaadin.terminal.gwt.client.ServerConnector; /** * Client side decoder for decodeing shared state and other values from JSON @@ -39,7 +39,8 @@ public class JsonDecoder { * @param jsonArray * JSON array with two elements * @param idMapper - * mapper between connector ID and {@link ServerConnector} objects + * mapper between connector ID and {@link ServerConnector} + * objects * @param connection * reference to the current ApplicationConnection * @return decoded value (does not contain JSON types) @@ -82,8 +83,7 @@ public class JsonDecoder { // TODO handle properly val = Boolean.valueOf(String.valueOf(value)); } else if (JsonEncoder.VTYPE_PAINTABLE.equals(variableType)) { - // TODO handle properly - val = idMapper.getConnector(String.valueOf(value)); + val = idMapper.getConnector(((JSONString) value).stringValue()); } else { // object, class name as type JSONSerializer serializer = serializerMap diff --git a/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/src/com/vaadin/terminal/gwt/server/JsonCodec.java index 4b3f41508e..44180e78c9 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonCodec.java +++ b/src/com/vaadin/terminal/gwt/server/JsonCodec.java @@ -20,6 +20,7 @@ import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.terminal.Paintable; +import com.vaadin.terminal.gwt.client.Connector; import com.vaadin.terminal.gwt.client.communication.JsonEncoder; /** @@ -35,6 +36,7 @@ public class JsonCodec implements Serializable { static { registerType(String.class, JsonEncoder.VTYPE_STRING); registerType(Paintable.class, JsonEncoder.VTYPE_PAINTABLE); + registerType(Connector.class, JsonEncoder.VTYPE_PAINTABLE); registerType(Boolean.class, JsonEncoder.VTYPE_BOOLEAN); registerType(Integer.class, JsonEncoder.VTYPE_INTEGER); registerType(Float.class, JsonEncoder.VTYPE_FLOAT); diff --git a/src/com/vaadin/ui/Component.java b/src/com/vaadin/ui/Component.java index 9c3f1a02f1..d3efb74118 100644 --- a/src/com/vaadin/ui/Component.java +++ b/src/com/vaadin/ui/Component.java @@ -18,6 +18,7 @@ import com.vaadin.terminal.Resource; import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.VariableOwner; import com.vaadin.terminal.gwt.client.ComponentState; +import com.vaadin.terminal.gwt.client.Connector; import com.vaadin.terminal.gwt.server.RpcTarget; /** @@ -53,8 +54,8 @@ import com.vaadin.terminal.gwt.server.RpcTarget; * @VERSION@ * @since 3.0 */ -public interface Component extends Paintable, VariableOwner, Sizeable, - Serializable, RpcTarget { +public interface Component extends Connector, Paintable, VariableOwner, + Sizeable, Serializable, RpcTarget { /** * Gets all user-defined CSS style names of a component. If the component -- 2.39.5