]> source.dussan.org Git - vaadin-framework.git/commitdiff
#4010 part 1: sending empty object arrays and maps (or null arrays/maps) between...
authorHenri Sara <henri.sara@itmill.com>
Mon, 25 Jan 2010 11:29:01 +0000 (11:29 +0000)
committerHenri Sara <henri.sara@itmill.com>
Mon, 25 Jan 2010 11:29:01 +0000 (11:29 +0000)
svn changeset:10985/svn branch:6.2

src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java

index 70cb99bc233617e69ea7ec8a3fbac6ca6c9c83a2..3b983e1d8659a6998c5a66d6f9fa663a3f8a8a3c 100755 (executable)
@@ -1324,11 +1324,12 @@ public class ApplicationConnection {
 
     /**
      * Sends a new value for the given paintables given variable to the server.
-     * <p>
+     * 
      * The update is actually queued to be sent at a suitable time. If immediate
      * is true, the update is sent as soon as possible. If immediate is false,
      * the update will be sent along with the next immediate update.
-     * </p>
+     * 
+     * A null array is sent as an empty array.
      * 
      * @param paintableId
      *            the id of the paintable that owns the variable
@@ -1342,11 +1343,13 @@ public class ApplicationConnection {
     public void updateVariable(String paintableId, String variableName,
             String[] values, boolean immediate) {
         final StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < values.length; i++) {
-            if (i > 0) {
-                buf.append(VAR_ARRAYITEM_SEPARATOR);
+        if (values != null) {
+            for (int i = 0; i < values.length; i++) {
+                if (i > 0) {
+                    buf.append(VAR_ARRAYITEM_SEPARATOR);
+                }
+                buf.append(values[i]);
             }
-            buf.append(values[i]);
         }
         addVariableToQueue(paintableId, variableName, buf.toString(),
                 immediate, 'c');
@@ -1354,11 +1357,13 @@ public class ApplicationConnection {
 
     /**
      * Sends a new value for the given paintables given variable to the server.
-     * <p>
+     * 
      * The update is actually queued to be sent at a suitable time. If immediate
      * is true, the update is sent as soon as possible. If immediate is false,
-     * the update will be sent along with the next immediate update.
-     * </p>
+     * the update will be sent along with the next immediate update. </p>
+     * 
+     * A null array is sent as an empty array.
+     * 
      * 
      * @param paintableId
      *            the id of the paintable that owns the variable
@@ -1372,18 +1377,20 @@ public class ApplicationConnection {
     public void updateVariable(String paintableId, String variableName,
             Object[] values, boolean immediate) {
         final StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < values.length; i++) {
-            if (i > 0) {
-                buf.append(VAR_ARRAYITEM_SEPARATOR);
-            }
-            Object value = values[i];
-            char transportType = getTransportType(value);
-            // first char tells the type in array
-            buf.append(transportType);
-            if (transportType == 'p') {
-                buf.append(getPid((Paintable) value));
-            } else {
-                buf.append(value);
+        if (values != null) {
+            for (int i = 0; i < values.length; i++) {
+                if (i > 0) {
+                    buf.append(VAR_ARRAYITEM_SEPARATOR);
+                }
+                Object value = values[i];
+                char transportType = getTransportType(value);
+                // first char tells the type in array
+                buf.append(transportType);
+                if (transportType == 'p') {
+                    buf.append(getPid((Paintable) value));
+                } else {
+                    buf.append(value);
+                }
             }
         }
         addVariableToQueue(paintableId, variableName, buf.toString(),
index 9c9af9d90d4de6b8dfc4dfce7a3e7754f69bb4e3..117d0bce7e051574e288caf9ddb5200166e59018 100644 (file)
@@ -1244,19 +1244,24 @@ public abstract class AbstractCommunicationManager implements
         HashMap<String, Object> map = new HashMap<String, Object>();
         for (int i = 0; i < parts.length; i += 2) {
             String key = parts[i];
-            char variabletype = key.charAt(0);
-            Object value = convertVariableValue(variabletype, parts[i + 1]);
-            map.put(key.substring(1), value);
+            if (key.length() > 0) {
+                char variabletype = key.charAt(0);
+                Object value = convertVariableValue(variabletype, parts[i + 1]);
+                map.put(key.substring(1), value);
+            }
         }
         return map;
     }
 
     private Object convertArray(String strValue) {
         String[] val = strValue.split(VAR_ARRAYITEM_SEPARATOR);
+        if (val.length == 0 || (val.length == 1 && val[0].length() == 0)) {
+            return new Object[0];
+        }
         Object[] values = new Object[val.length];
         for (int i = 0; i < values.length; i++) {
             String string = val[i];
-            // first char of string is typ
+            // first char of string is type
             char variableType = string.charAt(0);
             values[i] = convertVariableValue(variableType, string.substring(1));
         }