Deep client-side object cloning (GWT + Javascript)?

I know the Deep Cloning library in Java, which I use in my server-side code.

However, now I need to "deeply clone" the object on the client code. I believe there is a Javascript structure that does this thing, which is YUI3, however I am not sure how to use it with my GWT code.

+2
source share
2 answers

You can use JSNI to use the YUI3 code from the GWT code, however you will need to include the entire YUI3 source in your GWT application, which can be inefficient if you only need the deep clone feature.
If you have the source code for the deep cloning library for your java server, you can use it also on the GWT client if there are no external dependencies.
You can also check these resources for more information:

How to make a deep copy of an arbitrary object in GWT? GWT Deep Copy Overlay

+1
source

Another option I'm using is converting a Java object to JSON, and then converting back to a Java object.

, , , , clone() ( GWT).

0

All Articles