Search code examples
gwtrequestfactory

RequestFactory Diff Calculation and 'static' find method


Am bit stuck by these three questions:

1) I see that diff is calculated in AutoBeanUtils's diff method. I saw a tag called parentObject in the entity which is used in the comparison to calculate diff.

parent = proxyBean.getTag(Constants.PARENT_OBJECT); in AbstractRequestContext class.

Does that mean there are two copies for a given entity thats loaded on to the browser? If my entity actual size is say 1kb, actual data loaded will be 2kb (as two copies of entity are getting loaded onto the browser) ?

2) On the server side:

Suppose I have to fetch an entity from the database, the static find<EntityName> should be such that I have to make a db call every time, or is there a way where I can fine tune that behavior? [Sorry I did not understand the locator concept very well.]

3) What happens if there is a crash on the server side(for any reason which need not be current request specific) when a diff is sent from the client?

Thanks a lot.


Solution

    1. when you .edit() a proxy, it makes a copy and stores the immutable proxy you passed as argument as the PARENT_OBJECT of the returned proxy.

    2. you'd generally make a DB call every time the method is called (this is the same for a Locator's find() method), which will be no more than twice for each request. You can use some sort of cache if you need, but if you use JPA or JDO this is taken care of for you (you have to use a session-per-request pattern, aka OpenSessionInView)

    3. If there's any error while decoding the request, a global error will be returned, that will be passed to onFailure of all Receivers for the failed RequestContext request.

    See https://code.google.com/p/google-web-toolkit/wiki/RequestFactoryMovingParts#Flow