PDA

View Full Version : BaseModel type as a DTO



akme247
20 Jul 2009, 5:43 PM
Hi,

I'm new to using GXT.

I am using BaseModel sub type as return type from my RPC methods.

For instance,


Car extends BaseModel {
private String model;
private Date year;
private String make;
} RPC:


Car getCar(String clubMember); // returns the Car based on vinNow Car is a BaseModel type object, and I like to leverage the the API - addChangeListener(...) so I can get notified by the BaseModel when its property changes - for instance, let's say I had another property called - 'color' (may not be the best example, but just work with me here).

But since I use the Car as a DTO, the RPC would return me a 'new' Car object everytime. So attaching property change listener doesn't make sense, as the whole model is changed.

I want to have my View, only implement the modelChanged event - only for a 'updated/new' property value that might have changed, but not take actions on all value.

What is the best practice around this - as I really like the model observer pattern, but if I return new model (as DTO) for my RPC calls, it sort of defeats the purpose of using it intelligently.