Passing complex objects from client side GWT counterpart to Vaadin


I have a built my own CustomLayout widget extending fro the native classes. In the client side counterpart, VMyCustomLayout, I want to do this:

 HashMap<String, Object> event = new HashMap<String, Object>();
      event.put("event-name", eventName);
      event.put("event-data", eventData);
      client.updateVariable(pid, "my-event", event, true);

This will then eventually call the server side MyCustomLayout’s changeVariables method with the hashmap. If both my values in the hashMap are of type String i.e. ‘event-name’ and ‘event-data’, then it works absolutely fine. However if in ‘event-data’, I put a hashMap<String, String>, then in the MyCustomLayout’s changeVariables method, the value of ‘event-data’ comes out as null.
I looked into the internal code and see that when I put hashmap, then the transport type of this is ‘u’, which eventually doesn’t get translated and hence ‘null’ is set.

Can you pl. help me with this? My aim is to be able to be pass a hashMap inside another HashMap as described above.


Can anyone help me with this issue.
What my requirement basically reduces to is this:
Vaadin allows me to pass a HashMap<String, Object> object from its client side counterpart(using updateVariable) to the server side component, where it is de-serialized and made available in the ‘changeVariables’ method. As the HashMap signature suggests, the key has to be of type ‘String’, while the value can be an ‘Object’. So in this when my value is of type ‘String’, it gets passed as expected. However if the value is of type ‘HashMap’, then the de-serialized value at the server side comes out to be null. Is passing of a HashMap object as the value possible? If not what is the alternative besides breaking the HashMap into String objects?

Thanks in advance.

My initial guess without looking is that the behaviour is undefined if using objects.

Another approach would be to build a DTO of that hasmap and implement its own serialization which you then deserialize on the server side.


Values in that work in the maps that are sent from client to server:

If you are using some other types you should use some own custom serialization as suggested by John. JSON is one good option. You can then pass the JSON string via Vaadin communication mechanism.