Wednesday, May 30, 2012

RequestFactory - how to prevent batched requests after constraint violation

I am getting an IllegalArgumentException, Attempting to edit an EntityProxy previously edited by another RequestContext. This is a result of getting constraint violations and automatically batching different Request Factory requests within the RequestContext.
I am using GWT 2.4. My RequestContext interface has multiple methods save(), updateCache(), load(),...
 
Here is the scenario:
  1. Call save() which encounters server side constraint violations. The RequestContext is still active since the call did not complete.
  2. Try to correct the data. Make a change to the value of a field that happens to have an onChange handler that automatically calls updateCache() on the RequestContext. This causes the RequestContext to have 2 batched requests, save() and updateCache(). Both are then invoked via the single Request.fire() call.
  3. onSuccess() is called twice, once for save() and then once for updateCache(). OnSuccess() creates a new RequestContext instance and calls edit() on the driver. The second call to edit() within onSuccess() causes the IllegalArgumentException.
How can I remove or avoid the queued call to save() when receiving the constraint violations. Depending on the user's action after a constrain violation, a request other than save() may be called, so it is not just a matter of trying to re-fire the initial save() request, I am trying to make a different request and not call save() yet.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/dQ5uJt3NoYsJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment