Deep Cloning an object on the client side (GWT + Javascript) ?

I know of a Deep Cloning library in Java, which I use in my server side code.

However, right now I need to "deep clone" an object on the client side code. I believe there's a Javascript framework that does this thing which is YUI3, however I am not sure how to use this with my GWT code.



You could use JSNI to use YUI3 code from GWT Code, however you would have to include the whole YUI3 source in your GWT app which might be a litle bit inefficient if you only need the deep cloning functionality.
If you have the the source code for the deep cloning library for your java backend you might use it also on the GWT client if there are no external dependencies.
You can check out also these resources for more info:

How can I deep copy an arbitrary object in GWT?
GWT Overlay deep copy


Another option that I use is converting the Java object to JSON, and then converting back to a Java object.

Where this is not the cleanest way, there is answer to a different question that indicates that this is a faster way than the traditional clone() method (which is not supported in GWT).


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.