Friday, August 31, 2012

RequestFactory collects request calls after onConstraintViolation

Hi,

I have the following method in my activity:

public void rejectBankCheck(String remarks) {
request.rejectBankCheck(entity, remarks)
.fire(new Receiver<ProtocolProxy>() {

@Override
public void onSuccess(ProtocolProxy response) {
display.onRejectSuccess();
}
@Override
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
display.setConstraintViolations(violations);
}
});
}

On the UI, the user enters remarks and clicks on a button. This invokes rejectBankCheck() on the activity. The current request is now fired with the associated receiver. It happens that there are constraint violations which the user then corrects and reclicks on the button. This time, the receiver gets onSuccess(), so everything seems to be correct. But I can now see that, in this case, onSuccess() and the corresponding service method of rejectBankCheck() are called twice. Or several times if the user doesn't correct the constraint violations after the first call. This means that the request calls are collected by the requestcontext.

My first intention was to split this into two steps:
  1. Initialize the requestcontext when the activity starts: request.rejectBankCheck(entity, remarks).to(new Receiver...
  2. Call request.fire() when the user clicks on the button
This unfortunately isn't possible, since the parameter remarks (entered by the user) can change between two invocations.

Now my questions:
  1. Is this behaviour a bug or a feature of the request factory? I can't see where this would be useful. If it's a bug, I'll open an issue
  2. Can anyone see a workaround for this?

--
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/-/uVr1RG44M2EJ.
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