Re: RequestFactory collects request calls after onConstraintViolation response

98 views
Skip to first unread message

Thomas Broyer

unread,
Sep 3, 2012, 5:13:36 PM9/3/12
to google-we...@googlegroups.com


On Friday, August 31, 2012 11:43:23 AM UTC+2, Manuel Schrag wrote:
Hello,

We're having a problem using the request factory in GWT 2.5 RC1. When calling rejectBankCheck() on the activity, it happens that there are bean validation errors. The service method corresponding to this request call is not invoked. By correcting the errors on the UI and clicking on a button, rejectBankCheck() is called again. This time, the receiver gets onSuccess(). Everything looks fine, but I can see that both, onSuccess() and the service method corresponding to rejectBankCheck(), are invoked twice!

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);
          }
   });
}

My first intention was to split this in two steps:
  1. initialize the receiver when the activity starts
  2. when the user clicks on the button, just call fire() on the request context
This isn't possible, because the parameter remarks of the method is a user input and can change between the two invocations. So I have to call request.rejectBankCheck(entity, remarks) every time the user clicks.

Here are my questions:
  1. Is this a bug or a feature of the request factory? At the moment, I cannot see when this behaviour would be necessary or of any help.

Not a bug.
 
  1. Can anyone see a workaround for this?
Three:
  • either don't use validation on the server-side (either do it on the client-side before calling rejectBankCheck, or inside the rejectBankCheck method on the server-side and use a new RequestContext in the onFailure case)
  • fire() once without the rejectBankCheck to validate the proxies, then if OK create a new RequestContext, edit the proxies, call rejectBankCheck and fire again
  • move the remarks argument to a proxy so you can change it without the need to call rejectBankCheck again
 

Manuel Schrag

unread,
Sep 4, 2012, 9:11:16 AM9/4/12
to google-we...@googlegroups.com
Thank you for your response!!
  • fire() once without the rejectBankCheck to validate the proxies, then if OK create a new RequestContext, edit the proxies, call rejectBankCheck and fire again
 This approach worked for me in that case!

Cheers
Reply all
Reply to author
Forward
0 new messages