1
votes

I have several GWT Maps API JavaScriptObjects (LatLng, Polyline) which I want to send between the client and the server with RPC but becouse they aren't serializable I can't use them. Currently I have Pojos for RPC communication and I mirror them into their JavaScriptObject twins on the client side...

Is there any way to do send these objects through? I have the feeling I'm missing something about how should I do this.

1

1 Answers

1
votes

JavaScriptObjects are not real Java objects, so while they work in dev mode and when compiled to JavaScript, they can't work in a standard JVM, not connected to a browser. So no, you can't send the JSO to the server over RPC. A standard JVM won't even be able to load the class, since a JSO will have native methods, and the JVM won't have proper implementations of those methods.

If you can control the JSO, you might make both it and your POJO implement a common interface. For Maps API, you probably don't control it - a thought there could be to serialize the objects to JSON strings and just send those to the server. If the server then needs to read out the data, you might use Gson, Jackson, json.org, etc to read the data in those JSON strings.