I am trying to send an object similar to the UserModel object in the Dozer tutorial back to my client through GWT-RPC.
However, I am getting a warning that points out that the Model contained within UserModel (namely, the AddressModel) cannot properly be serialized.
Is there something about which I need to be aware for any child Model objects to be serialized properly?
[WARN] StandardContextException while dispatching incoming RPC call
Caused by: com.google.gwt.user.client.rpc.SerializationExcept ion: Type 'com.softroots.sonic.client.model.AddressModel' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.
I experienced this problem earlier. Seems the GWT serializer doesn't like GXT model objects containing other GXT model objects, especially if one contains a collection of the other I think.
Workarounds I found couple of months ago:
1. Make your model objects inherit from BaseTreeModel instead of BaseModel
or
2. Add a dummy field to your containing model object, e.g. "private Integer private = 1;"
and make sure it implements Serializable
Try it out and tell us how it goes
Thank you for the response. Unfortunately, none of the suggestions worked, nor a combination of the suggestions worked.
Darrell, in your tests, can you try sending an object graph of Models through the GWT-RPC??
GWT does not "see" the types stored in the internal map. Add a dummy field to your subclass with a type of AddressModel. If you still have problems then post your code for UserModel. Both AddressModel and UserModel should implement Serialazable directly, not via a subclass.
Two questions before I plunge into this, as this looks like a terrific solution.
1) I assume that since this works with stores, I will be able to use this solution for anything that uses a store (tables, lists...) and not just the Grid you provided as an example?
2) Does this handle nested-objects correctly as the simple work-around for the BaseModel does?
I am looking forward to using this!
Do your model objects have zero arg constructors?
Yes, adding the dummy field of the type that was causing the serialization problem worked.
Grandiosa and Darrell, thank you both for your assistance. Hopefully this helps others as well!
Yes. They do have zero-argument constructors.
Have you any idea why subclassing from BaseModel or BaseModelData does not allow nested Models to be properly serialized? Would it be futile to try and rewrite my own BaseModel for serialization? Is this a bug in the models?
Take a look at this blog post for new Java Bean support. With this approach, you can send any bean (not GXT models) objects via RPC and use then with a Store.
1) I assume that since this works with stores, I will be able to use this solution for anything that uses a store (tables, lists...) and not just the Grid you provided as an example?
Yes.
2) Does this handle nested-objects correctly as the simple work-around for the BaseModel does?
Not at this time. However, I hope to add this feature soon.
Nortel Unveils Vision, Strategy for Israeli High-Performance Net
Busy Friday Leads to Strong Close for Net Stocks
|