All components are serializable, so you can serialize components to the memory or other storage and de-serialize them later. Like cloning, the de-serialized components don't belong to another page (and desktop). They are also independent of the one being serialized. As illustrated below, serialization can be used to implement the similar cloning function.
<vbox id="vb"> <listbox id="src" multiple="true" width="200px"> <listhead> <listheader label="Population"/> <listheader align="right" label="%"/> </listhead> <listitem value="A"> <listcell label="A. Graduate"/> <listcell label="20%"/> </listitem> <listitem value="B"> <listcell label="B. College"/> <listcell label="23%"/> </listitem> <listitem value="C"> <listcell label="C. High School"/> <listcell label="40%"/> </listitem> </listbox> <zscript> int cnt = 0; </zscript> <button label="Clone"> <attribute name="onClick"> import java.io.*; ByteArrayOutputStream boa = new ByteArrayOutputStream(); new ObjectOutputStream(boa).writeObject(src); Listbox l = new ObjectInputStream( new ByteArrayInputStream(boa.toByteArray())).readObject(); l.setId("dst" + ++cnt); vb.insertBefore(l, self); </attribute> </button> </vbox>
Of course, cloning with the clone method has much better performance, while serialized components can be used crossing different machines.