Thanks, Gert.  A deep copy works if implemented as

                Map<String, List<String>> paramMap = 
Window.Location.getParameterMap
();
                HashMap<String, List<String>> map = new HashMap<String, 
List<String>>
();
                Set<String> keys = paramMap.keySet();
                for ( String key : keys ) {
                        List<String> list = paramMap.get(key);
                        ArrayList<String> alist = new ArrayList<String>();
                        for ( String value : list )
                                alist.add(value);
                        map.put(key, alist);
                }

I'm suspecting the problem is relying on interfaces alone, since

                Map<String, List<String>> paramMap = 
Window.Location.getParameterMap
();
                HashMap<String, List<String>> map = new HashMap<String, 
List<String>>
();
                Set<String> keys = paramMap.keySet();
                for ( String key : keys )
                        map.put(key, paramMap.get(key));

did NOT work.  Once List becomes ArrayList, all is well.

On Jul 14, 5:09 am, Gert Scholten <[email protected]> wrote:
> On Jul 14, 12:31 am, Thad <[email protected]> wrote:
>
>
>
> > I see references to problems with serializing Map objects across the
> > RPC layer.  From what I read, folks have a lot of trouble with this,
> > but that is should work.  Well, it's not working for me.
>
> > I have an application to which I wish pass the parsed query string to
> > the server, as in MyAppl.html?foo=bar&eanie=meanie
> > In client/MyAppl.java I call
> > Map<String, List<String>> paramMap = Window.Location.getParameterMap
> > ();
>
> > Now I call myService.execute(paramMap, callback).  This fails, whether
> > passed as a Map or as "new HashMap(paramMap)".  The first line in my
> > service is a System.out.println() and it never gets called.  I'm
> > tossed right into my callback's onFailure() method. (The Throwable's
> > getMessage() is "[ERROR] java.util.Collections
> > $UnmodifiableRandomAccessList
> > com.google.gwt.user.client.rpc.SerializationException:
> > java.util.Collections$UnmodifiableRandomAccessList").
>
> > What gives?  A HashMap implements serializable.  The keys are Strings
> > and the value is a List of Strings.
>
> > Why won't this serialize?
>
> That is a good question...
> It is because the java.util.Collections$UnmodifiableRandomAccessList
> class is not supported for serialization, it it correct that the call
> will never reach your servlet. Imo, it shouldn't even compile if this
> is intended behavior. That said, according to the docs 
> athttp://code.google.com/webtoolkit/doc/1.6/RefJreEmulation.html#Packag...
> the Collections.unmodifiableList(List) method _is_ supported, which
> makes it doubly odd that it's result won't serialize.
>
> The workaround is doing a deep copy of your UnmodifiableHashMap,
> instead of the shallow copy you do with the copy constructor. Go for:
> HashMap copy = new HashMap();
> for (Entry<String, List<String>> e : paramMap.entrySet()) {
>   copy.put(e.getId(), new ArrayList(e.getValue());
>
> }
>
> Regards,
>   Gert
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to