I strongly recommend to use DTO's because then you have all the benefits of type-safety which is one of the most compelling reasons to use GWT.
however, if you really don't care about that, you could use a HashMap<String, String> and simply call the toString() method on the serverside for every value you want to put into the map. On 12 Mrz., 09:38, kriswpl <kris...@gmail.com> wrote: > Thank you Paul for your reply. > > FYI - I use Map not to use DTO - I put all properties (Long, Date) to > this Map. > > So I have another question --- is it any way to define what kind of > objects (Date, Long, Double, etc.) can show in Map. I found > information @gwt.typeArgs <something>. > I mean - is it possible to add to the remote interface information > about all serializaed types which can be in Map? - to solve this > problem > > Thanks, > Krisw > > On 11 Mar, 17:55, Paul Robinson <ukcue...@gmail.com> wrote: > > > kriswpl wrote: > > > Interface method is: > > > public Map<String, Object> test(); > > > > and in implementation I put into returned map, object java.util.Long > > > (which is serializable:) ): > > > map.put("long", new Long(1)); > > > > Where do I do it wrong? > > > GWT does a great job of putting as little into the javascript as > > possible. In the above case, there's nothing to tell it that you're > > going to send a Long, so it doesn't generate the RPC code into the > > javascript that knows how to deserialize a Long. Add another method that > > references Long, and then your first method might work because the Long > > code is now going to be included. > > > On a related note, using Map in the API is not a good idea because it > > means GWT must look through all your code for every implementation of > > Map to see whether it's used. At the very least, it will make compiles > > take longer. At worst, it will generate longer code. It goes against the > > grain for java programming, but you need to make GWT RPC APIs as > > specific as possible. That means declaring that you're returning a > > HashMap, not a Map, in the interface. > > > This also means you can't declare Object as a type in an RPC interface. > > > Paul -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.