I just created simple emulation with the following two classes below.
It doesn't have the functionality of a real ObjectId (e.g. no
getTime()) but it allowed me to pass my objects via RPC. I found the
documentation on how to emulate classes a bit lacking but this page
http://code.google.com/p/wogwt/wiki/CustomFieldSerializer
was helpful as well as looking at the source from this project
http://code.google.com/p/gwtx/
package org.bson.types;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.SerializationStreamReader;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
public final class ObjectId_CustomFieldSerializer {
public static void deserialize(SerializationStreamReader
streamReader, ObjectId instance)
throws SerializationException {
}
public static ObjectId instantiate(SerializationStreamReader
streamReader)
throws SerializationException {
String id = streamReader.readString();
return new ObjectId(id);
}
public static void serialize(SerializationStreamWriter streamWriter,
ObjectId instance)
throws SerializationException {
streamWriter.writeString(instance.toString());
}
}
package org.bson.types;
public class ObjectId implements java.io.Serializable {
final String id;
public ObjectId(String id) {
this.id = id;
}
public String toString() {
return id;
}
}
On Oct 12, 10:20 am, Yves <
yveshw...@gmail.com> wrote:
> Hi guys,
>
> just wondering if anybody can suggest an elegant work around for
> emulating ObjectId for GWT module at the moment. (issue 103
http://code.google.com/p/morphia/issues/detail?id=103)