diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-02-05 11:42:19 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-02-05 11:42:19 +0200 |
commit | 28b7703d29d93f0fefc7e020d9f7cf14c0349aa7 (patch) | |
tree | 51bfbe2ff4a0608613f902a5cd3aa1cc3e743df6 | |
parent | 83e262186da502fecc79d6851815260770d7e3a6 (diff) | |
download | vaadin-framework-28b7703d29d93f0fefc7e020d9f7cf14c0349aa7.tar.gz vaadin-framework-28b7703d29d93f0fefc7e020d9f7cf14c0349aa7.zip |
Don't fetch old bean property value if it is not needed (#10940)
Change-Id: I6231eedef94c402457fc4cb217366a3e08f1492c
-rw-r--r-- | client/src/com/vaadin/client/communication/JsonDecoder.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/communication/JsonDecoder.java b/client/src/com/vaadin/client/communication/JsonDecoder.java index 75af42fc1e..d32cdd92aa 100644 --- a/client/src/com/vaadin/client/communication/JsonDecoder.java +++ b/client/src/com/vaadin/client/communication/JsonDecoder.java @@ -30,6 +30,7 @@ import com.google.gwt.json.client.JSONString; import com.google.gwt.json.client.JSONValue; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ConnectorMap; +import com.vaadin.client.FastStringSet; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Property; import com.vaadin.client.metadata.Type; @@ -48,6 +49,24 @@ import com.vaadin.shared.Connector; */ public class JsonDecoder { + private static final FastStringSet decodedWithoutReference = FastStringSet + .create(); + static { + decodedWithoutReference.add(String.class.getName()); + decodedWithoutReference.add(Boolean.class.getName()); + decodedWithoutReference.add(Byte.class.getName()); + decodedWithoutReference.add(Character.class.getName()); + decodedWithoutReference.add(Short.class.getName()); + decodedWithoutReference.add(Integer.class.getName()); + decodedWithoutReference.add(Long.class.getName()); + decodedWithoutReference.add(Float.class.getName()); + decodedWithoutReference.add(Double.class.getName()); + decodedWithoutReference.add(Connector.class.getName()); + decodedWithoutReference.add(Map.class.getName()); + decodedWithoutReference.add(List.class.getName()); + decodedWithoutReference.add(Set.class.getName()); + } + /** * Decode a JSON array with two elements (type and value) into a client-side * type, recursively if necessary. @@ -134,8 +153,17 @@ public class JsonDecoder { if (encodedPropertyValue == null) { continue; } - Object propertyReference = property.getValue(target); - Object decodedValue = decodeValue(property.getType(), + + Type propertyType = property.getType(); + + Object propertyReference; + if (needsReferenceValue(propertyType)) { + propertyReference = property.getValue(target); + } else { + propertyReference = null; + } + + Object decodedValue = decodeValue(propertyType, encodedPropertyValue, propertyReference, connection); property.setValue(target, decodedValue); } @@ -147,6 +175,10 @@ public class JsonDecoder { } } + private static boolean needsReferenceValue(Type type) { + return !decodedWithoutReference.contains(type.getBaseTypeName()); + } + private static Map<Object, Object> decodeMap(Type type, JSONValue jsonMap, ApplicationConnection connection) { // Client -> server encodes empty map as an empty array because of |