what i'm trying to do is gather several request all together and fire them once my code :
RequestContext contextA =requestFactory
.dataRequest().save(...).to(...);
RequestContext contextB =requestFactory
.itemRequest().save(...).to(...);
requestA.append(requestB);
requestA.fire();
dataRequest and item request both extends RequestContext
when im trying to do this like that i got:
Caused by: java.lang.IllegalStateException: The provided RequestContext has been changed
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.append(AbstractRequestContext.java:484)
so what im doing wrong?
The argument to append() must be clean RequestContext.
You can change your code to:
ItemRequest contextB = requestFactory.itemRequest();
contextA.append(contextB);
contextB.save(...).to(...);
or more simply:
requestA.append(requestFactory.itemRequest()).save(...).to(...);
Rationale: internally, appended RequestContexts use a shared state; when calling append(), the internal state of the appended RequestContext is replaced with the one you're appending to. If it's not empty, you'd lose data (there's no merging), so it simply fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With