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:
- Call save() which encounters server side constraint violations. The RequestContext is still active since the call did not complete.
- 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.
- 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.