Parsing a Map object to client...

Hi all,

I’m trying to send some data across to the client from my server by using the following code inside the
paintContent(PaintTarget target)
method.

target.addAttribute("mymap", map); 

But when I try to read the map that I passed from the
updateFromUIDL(UIDL uidl, ApplicationConnection client)
method, what I’m getting is a
ValueMap
.

ValueMap map = uidl.getMapAttribute("mymap"); // This is not a java.util.Map

I have already asked the same question in the below link & the reply that I got is related to serialization & de-serialization of Strings.

http://vaadin.com/forum/-/message_boards/message/203445

My concern is to get the same map that I passed from the server side.
Is there a way to accomplish this?

Any help is greatly appreciated.

Thanks,
Asela.

Even though the client side implementation is different, the contents should be the same that you send. Use getString/getInt/getBoolean or similar depending on what type of data you have put in your map.

Hi Artur,

Thanks for the quick reply. I do have a question about the following.

What if I’m using
my own Objects
as the values for the map?

Map<Long, MyObject> map = new HashMap<Long, MyObject>();
map.put(1L, new MyObject(long, String, ArrayList,... some other objects));

Do I have to write a de-serialization class in the client side as mentioned in the previous thread by
John Ahlroos
?

http://vaadin.com/forum/-/message_boards/message/203445

Thanks,
Asela.

If you are using other types of objects you need to serialize/deserialize them manually. Hopefully this will be improved in Vaadin 7.