Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly add RequestContexts

Tags:

request

gwt

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?

like image 654
user902383 Avatar asked Mar 07 '26 04:03

user902383


1 Answers

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.

like image 170
Thomas Broyer Avatar answered Mar 10 '26 01:03

Thomas Broyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!