Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    com.smartgwt.client.data.DSCallback no support for onFailure()

    Hello,

    We are using SmartGWT 2.5 and I am using DynamicForm.saveData(new DSCallback()) method to submit the form to a data source. When the data is processed without failures, the execute() method is called which is all great. My problem is that DSCallback interface does not mention any other methods I'd need to implement to handle failures.

    Any suggestions or hints are very appreciated.
    Thanks,
    Henry

    #2
    Failures such as validation errors are handled automatically by the form. Unrecoverable errors go to central error handling on RPCManager (addErrorHandler). If you want the callback on saveData() to fire for both of these, set rpcRequest.willHandleError:true on the dsRequestProperties.

    Comment


      #3
      Thank you for a quick reply. I am not sure how to change the dsRequestProperties. I am not actually referencing DSRequest anywhere in my code. Here is my code:
      Code:
      //when button click event is fired
      form.saveData(new DSCallback() {
          @Override
           public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
                 Record[] records = dsResponse.getData();
                 // process the response contained in records
           }
      }
      Not sure where I need to reference and modify the rpcRequest.

      What about form.addFormSubmitFailedHandler()? would that be useful in this case?

      thanks.

      Comment


        #4
        Read the docs for form.saveData() - there's a signature that let's you pass a DSRequest that contains properties for the DSRequest.

        Comment


          #5
          Thank you again! It worked great. If anyone else stumbles on this, the answer is rather simple:

          Code:
          DSRequest dsRequest = new DSRequest();
          dsRequest.setWillHandleError(true);
          
          form.saveData(new DSCallback() {
              @Override
               public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
                     if(dsResponse.getStatus() != DSResponse.STATUS_SUCCESS){
                          //handle error
                     }
                     Record[] records = dsResponse.getData();
                     // process the response contained in records
               }
          }, dsRequest);

          Comment

          Working...
          X