title: Validating multiple asyncronous methods in GWT
body: <p>I am looking at a code that I have to work on.  And basically I have to add a validation to a listener of a button.
  The code has already multiple validations.  They are kind of set in a cascade. 
  The listener of the buttons calls an asyncCallBack method that if everything is ok, on the onsuccess part of the method calls for the next one, an that one on the next one, until it reaches the end and goes to the next page.  I am not a fan of this approach because it is kind of messy.  What would the best way to do that using best practices.</p>
  
  <p>An example of the code:</p>
  
  <pre><code>Button btnOK = new Button("Aceptar");
  btnOK.addListener(Events.Select, new Listener&lt;ButtonEvent&gt;() {
  public void handleEvent(ButtonEvent e) {
      myService.getInfo1(1, txt, "N",
          new AsyncCallback&lt;List&lt;InfoService&gt;&gt;() {
              public void onFailure(Throwable caught) {
              // goes back
                  return
              }
  
              public void  onSuccess(
                  List&lt;Object&gt; result) {
                      // do some validation with the result
                      validation2();
                  }
  
          }
      }
  }
  
  public void validation2(){
      myService.getDireccionCanalesElectronicos(id, new AsyncCallback&lt;MyResult&gt;() {
          public void onSuccess(MyResult result) {
              // do some validation with the result
              validation3();
          }
          ...
      }
  }
  
  public void validation3(){
      myService.getDireccionCanalesElectronicos(id, new AsyncCallback&lt;MyResult&gt;() {
          public void onSuccess(MyResult result) {
              // do some validation with the result
              validation4();
          }
          ...
      }
  }
  </code></pre>
  
  <p>Is there a better way of doing this, it seems messy and hard to follow. Adding another validation is complicated. It doesnt seem like a good practice.</p>