1

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I see. I knew they aren't java classes a JVM could load but I didn't know how to elegantly solve this problem. Maybe talking in JSON is the best approach. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.