Announcement

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

    Inconsistent error handling with custom operation

    I have a field in a ListGrid which has an EditorExit handler that makes a DMI call using DataSource.performCustomOperation. In some cases when the DSResponse has a status of VALIDATION_ERROR the field listed in the error is automatically flagged in the ListGrid record with the error icon. In other cases, with the exact same response coming back, instead of the ListGrid field being flagged with the error a pop-up warning message appears with the message "Server returned VALIDATION_ERROR with no error message performing operation 'custom'."

    Here is the request/response which results in the pop-up message.
    Code:
    // Request
    {
        "dataSource":"PoPackContents", 
        "operationType":"custom", 
        "operationId":"getDefaults", 
        "data":{
            "packCompItemNumber":"white", 
            "packItemNumber":"0280-00280-0333-100-1001", 
            "SizeScale":"1 2 3 4", 
            "ValidSizes":""
        }, 
        "showPrompt":true, 
        "prompt":"Validating component item number ...", 
        "oldValues":{
            "packCompItemNumber":"white", 
            "packItemNumber":"0280-00280-0333-100-1001", 
            "SizeScale":"1 2 3 4", 
            "ValidSizes":""
        }, 
        "requestId":"PoPackContents$627152"
    }
    
    // Response
    [
        {
            queueStatus:-1, 
            errors:[
                {
                    packCompItemNumber:{
                        errorMessage:"Please enter a valid item number."
                    }
                }
            ], 
            isDSResponse:true, 
            invalidateCache:false, 
            status:-4, 
            data:null
        }
    ]
    Here is the request/response which results in the normal error flagging on the field. There is no difference between the two responses, just a couple of different fields included on the request. Why would that make a difference in how the error response is handled?
    Code:
    // Request
    {
        "dataSource":"PoPackContents", 
        "operationType":"custom", 
        "operationId":"getDefaults", 
        "data":{
            "packCompItemNumber":"white", 
            "packItemNumber":"0280-00280-4567-100-1001", 
            "IsValid":""
        }, 
        "willHandleError":true, 
        "showPrompt":true, 
        "prompt":"Validating component item number ...", 
        "oldValues":{
            "packCompItemNumber":"white", 
            "packItemNumber":"0280-00280-4567-100-1001", 
            "IsValid":""
        }, 
        "requestId":"PoPackContents$627175"
    }
    // Response
    [
        {
            queueStatus:-1, 
            errors:[
                {
                    packCompItemNumber:{
                        errorMessage:"Please enter a valid item number."
                    }
                }
            ], 
            isDSResponse:true, 
            invalidateCache:false, 
            status:-4, 
            data:null
        }
    ]

    #2
    What's the exact date of your build?

    Can you clarify what's going on here - if you're calling performCustomOperation programmatically from EditorExit, this should not cause a validation error to appear in the ListGrid. Those only appear when an end user action causes the ListGrid to attempt a save.

    Now if you were to separately attempt an updateData and return an server-side validation error and not set willHandleError true to handle this yourself, you could get this error message.

    Perhaps a validation error being shown due to a separate, automatically issued request and it's not related to this problem?

    Comment


      #3
      SmartClient Version: SC_SNAPSHOT-2011-04-22/PowerEdition Deployment (built 2011-04-22)

      I've added willHandleError(true) and am now calling setFieldError() to flag the list grid field with the error. That works reliably.

      I suppose I should have done that anyway, but initial tests showed that calling performCustomOperation programmatically from EditorExit and having that operation return a validation error did cause the errors to appear in the ListGrid. So it seemed to magically work until we found this variant in the request where we started to see the pop-up warning instead.

      Comment


        #4
        I'm having the same issue and trying to handle the errors myself but not sure how to pass willHandleError. I am calling updateData on toggle of a checkbox.

        Code:
         element.grid.updateData(record, 
        function(data){
                    @com.conceptwave.gwt.client.Velocity::endActionChain()();
                  }, {willHandleError:true}
                )

        Comment


          #5
          If you want to have the grid handle saving and automatically show errors
          1. setEditValue()
          2. saveEdits()

          If you want to handle saving on your own and manually show errors:
          1. dataSource.updateData() (not grid.updateData())
          2. listGrid.setFieldError()

          Comment


            #6
            oh. I see that saveEdits also has callback. Ok I will try this. Thanks

            Comment


              #7
              I am saving the validation errors that are returned from the updateData() call and processing them when the rowEditorExit is called. I see programmatically that the errors are being set, but the grid does not show the validation error icons. How do I force the validations to show?


              Code:
                rowEditorExit: function(editCompletionEvent, record, newValues, rowNum){
                  
                  if(!this.rowHasChanges (rowNum) && this.cwErrors!=null){
                  
                    this.setRowErrors(rowNum, this.cwErrors);
                    this.refreshRow(rowNum);
                    this.cwErrors = null;
                  }
                },

              Comment


                #8
                Consider whether you want to start down this path. It's very tricky to implement custom validation errors applied via setRowErrors() et al. The problem is, because you're not supplying a validator we can call to check if the data is now valid or still invalid, the errors will generally be cleared every time to built-in validators run, and that's probably what's happening here, since by default exiting the row triggers a save. So supply actual validators (server or client-side) if at all possible.

                Comment


                  #9
                  Here is my real problem - I don't really need to go this route.

                  Each row has a "trigger" functionality on one field. When this field value is changed, server call is done, validation is fired on the server side and returned to the browser. My problem originally was that I was getting the message "Server returned VALIDATION_ERROR with no error message performing operation '$ds_update'." " even though I was returning the validation errors. So I figure maybe it is because my listgrid is still in edit mode. So I started going down this route. Maybe I can just provide the dsresponse and you can check what is missing?

                  Comment


                    #10
                    Yeah that's a better approach :)

                    One possible cause to check right away - do the errors possible refer to a fieldName that's not present in the grid?

                    Comment


                      #11
                      I don't think that is a problem - because the validation does get fired if I go exit out of edit mode.


                      DSRequest
                      Code:
                      {
                          "dataSource":"page$content$currentUI$ccards$manyCF$cardsFinder$$content$offLineFrame$content$contentUI$ccCardsFormFrame$content$cardsCFForm$contentForm$comrcialCardsFinderFrame$multiplecardsFinderResultTable1$ds", 
                          "operationType":"update", 
                          "componentId":"page$content$currentUI$ccards$manyCF$cardsFinder$$content$offLineFrame$content$contentUI$ccCardsFormFrame$content$cardsCFForm$contentForm$comrcialCardsFinderFrame$multiplecardsFinderResultTable1", 
                          "data":{
                              "cwPK__":"10129036", 
                              "checked":false, 
                              "rowNum":"1", 
                              "name":"", 
                              "cardNum":"", 
                              "numOfCopies":"1", 
                              "pin":"", 
                              "confirmPin":"", 
                              "featurePackage":"org.mozilla.javascript.Undefined@fabb0b", 
                              "expMonth":1, 
                              "year":"", 
                              "range":"", 
                              "termReset":1, 
                              "amount":"100", 
                              "getEditImage":null
                          }, 
                          "showPrompt":false, 
                          "oldValues":{
                              "cwPK__":"10129036", 
                              "checked":false, 
                              "rowNum":"1", 
                              "name":"", 
                              "cardNum":"", 
                              "numOfCopies":"1", 
                              "pin":"", 
                              "confirmPin":"", 
                              "featurePackage":"org.mozilla.javascript.Undefined@fabb0b", 
                              "expMonth":1, 
                              "year":"", 
                              "range":"", 
                              "termReset":1, 
                              "amount":"100", 
                              "getEditImage":null
                          }, 
                          "requestId":"page$content$currentUI$ccards$manyCF$cardsFinder$$content$offLineFrame$content$contentUI$ccCardsFormFrame$content$cardsCFForm$contentForm$comrcialCardsFinderFrame$multiplecardsFinderResultTable1$ds$6277"
                      }
                      DSResponse:

                      Code:
                      [
                          {
                              errors:[
                                  {
                                      year:{
                                          errorMessage:"Please select Expiration Year.\t"
                                      }
                                  }
                              ], 
                              isDSResponse:true, 
                              invalidateCache:false, 
                              status:-4, 
                              data:null
                          }
                      ]

                      Comment


                        #12
                        This request and response, taken in isolation, in fine. But as far as the code, you seemingly can only get this error message if the errors are malformed or missing. Can you give us any details that would allow us to reproduce the problem?

                        Comment


                          #13
                          I do not really do much before I receive the error except for the following: I have a clickTableCell function for the listgrid which calls the following code when the column is clicked:

                          this.updateData(record,
                          function(dsResponse, data, dsRequest){
                          @com.conceptwave.gwt.client.Velocity::endActionChain()();
                          }
                          )

                          listgrid goes into edit mode, updateData sends a update request(in which order, I'm not sure), then the message pops up.

                          Comment


                            #14
                            Any ideas?

                            Comment


                              #15
                              Sorry, we're still stuck without some way of reproducing this (the only thing you showed us is a call to some other method, after the update's already been processed).

                              Comment

                              Working...
                              X