Announcement

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

    DMI Validation

    We am using SmartGWT power 2.4

    I created a serverside DMI validation. It presently just returns the condition false and sets the error message.

    On the client side we've defined a form with items which come from the datasource. When we issue a validate the DMI validation is excuted and the error message is displayed on the console. The return from the validate call will always return true. If we issue a saveData on the form the validation is run again and returns errors but the save is allowed to continue.

    I can't seem to get the validation to work so as to prevent the save. I also can't seem to have visibility to the error message from the client.

    I've attached the ds and the DMI.
    Attached Files

    #2
    Can you show the RPC requests involved (from the RPC tab in the Developer Console) and the server-side logs for the requests?

    Note: this is always information we'll need for a problem of this kind.

    Comment


      #3
      ---First Validate which returns true
      {
      "dataSource":"PoApproval",
      "operationType":"validate",
      "data":{
      "PrintPo":true,
      "PrintPackAndShipReports":"N",
      "PrintStoreRecievingWorksheet":"N",
      "PrintTicketOrderReport":true,
      "PrintTotalsByColor":false,
      "PrintTotalsBySize":false,
      "PrintPrepackComponentInformation":true,
      "PoList":[
      "188323"
      ],
      "FileGroupNumber":312
      },
      "willHandleError":true,
      "showPrompt":true,
      "prompt":"Validating...",
      "oldValues":{
      "PrintPo":true,
      "PrintPackAndShipReports":"N",
      "PrintStoreRecievingWorksheet":"N",
      "PrintTicketOrderReport":true,
      "PrintTotalsByColor":false,
      "PrintTotalsBySize":false,
      "PrintPrepackComponentInformation":true,
      "PoList":[
      "188323"
      ],
      "FileGroupNumber":312
      },
      "clientContext":{
      "component":[DynamicForm ID:isc_DynamicForm_14],
      "fieldName":"PoList",
      "rowNum":null
      },
      "requestId":"PoApproval$62747"
      }

      -Repsonse

      [
      {
      queueStatus:-1,
      errors:[
      {
      recordPath:"/PoApproval",
      PoList:{
      errorMessage:"PO Not Approved"
      },
      FileGroup:{
      errorMessage:"Field is required"
      }
      }
      ],
      isDSResponse:true,
      invalidateCache:false,
      status:-4,
      data:null
      }
      ]


      ----Second Validate from saveData
      {
      "dataSource":"PoApproval",
      "operationType":"validate",
      "data":{
      "PrintPo":true,
      "PrintPackAndShipReports":"N",
      "PrintStoreRecievingWorksheet":"N",
      "PrintTicketOrderReport":true,
      "PrintTotalsByColor":false,
      "PrintTotalsBySize":false,
      "PrintPrepackComponentInformation":true,
      "PoList":[
      "188323"
      ],
      "FileGroupNumber":312
      },
      "willHandleError":true,
      "showPrompt":true,
      "prompt":"Validating...",
      "oldValues":{
      "PrintPo":true,
      "PrintPackAndShipReports":"N",
      "PrintStoreRecievingWorksheet":"N",
      "PrintTicketOrderReport":true,
      "PrintTotalsByColor":false,
      "PrintTotalsBySize":false,
      "PrintPrepackComponentInformation":true,
      "PoList":[
      "188323"
      ],
      "FileGroupNumber":312
      },
      "clientContext":{
      "component":[DynamicForm ID:isc_DynamicForm_14],
      "fieldName":"PoList",
      "rowNum":null
      },
      "requestId":"PoApproval$62748"
      }

      -- Repsonse
      [
      {
      queueStatus:-1,
      errors:[
      {
      recordPath:"/PoApproval",
      PoList:{
      errorMessage:"PO Not Approved"
      },
      FileGroup:{
      errorMessage:"Field is required"
      }
      }
      ],
      isDSResponse:true,
      invalidateCache:false,
      status:-4,
      data:null
      }
      ]

      -- Add request which is done with the save
      {
      "dataSource":"PoApproval",
      "operationType":"add",
      "componentId":"isc_DynamicForm_14",
      "data":{
      "PrintPo":true,
      "PrintPackAndShipReports":"N",
      "PrintStoreRecievingWorksheet":"N",
      "PrintTicketOrderReport":true,
      "PrintTotalsByColor":false,
      "PrintTotalsBySize":false,
      "PrintPrepackComponentInformation":true,
      "PoList":[
      "188323"
      ],
      "FileGroupNumber":312,
      "PoStatusList":[
      {
      "StatusCode":"*NO COMP ITEM ",
      "PoNumber":"188323",
      "StatusMessage":"Prepack components were not found",
      "IsError":true
      }
      ]
      },
      "callback":{
      "target":[DynamicForm ID:isc_DynamicForm_14],
      "methodName":"saveEditorReply"
      },
      "showPrompt":true,
      "prompt":"Approving blockout 188323",
      "oldValues":{
      },
      "clientContext":{
      },
      "requestId":"PoApproval$62749"
      }

      -Response
      [
      {
      queueStatus:0,
      isDSResponse:true,
      invalidateCache:false,
      status:0,
      data:{
      PoStatusList:[
      {
      StatusCode:"*NO COMP ITEM ",
      PoNumber:"188323",
      StatusMessage:"Prepack components were not found",
      IsError:true
      }
      ]
      }
      }
      ]



      --- Server Console logs

      === 2011-02-05 13:21:36,955 [l0-4] DEBUG ValidationContext - [builtinApplication.PoApproval_validate] Adding validation errors at path '/PoApproval/PoList': {errorMessage=PO Not Approved}
      === 2011-02-05 13:21:36,955 [l0-4] DEBUG ValidationContext - [builtinApplication.PoApproval_validate] Adding validation errors at path '/PoApproval': {errorMessage=Field is required}
      === 2011-02-05 13:21:36,955 [l0-4] INFO Validation - [builtinApplication.PoApproval_validate] Validation error: [
      {
      recordPath:"/PoApproval",
      PoList:{
      errorMessage:"PO Not Approved"
      },
      FileGroup:{
      errorMessage:"Field is required"
      }
      }
      ]
      === 2011-02-05 13:21:36,955 [l0-4] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2011-02-05 13:21:36,970 [l0-4] DEBUG RPCManager - non-DMI response, dropExtraFields: false
      === 2011-02-05 13:21:37,033 [l0-4] INFO RequestContext - URL: '/ipgui/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)': Moz (Gecko) with Accept-Encoding header
      === 2011-02-05 13:21:37,033 [l0-4] DEBUG XML - Parsed XML from (in memory stream): 0ms
      === 2011-02-05 13:21:37,048 [l0-4] DEBUG RPCManager - Processing 1 requests.
      === 2011-02-05 13:21:37,080 [l0-4] DEBUG RPCManager - Request #1 (DSRequest) payload: {
      values:{
      PrintPo:true,
      PrintPackAndShipReports:"N",
      PrintStoreRecievingWorksheet:"N",
      PrintTicketOrderReport:true,
      PrintTotalsByColor:false,
      PrintTotalsBySize:false,
      PrintPrepackComponentInformation:true,
      PoList:[
      "188323"
      ],
      FileGroupNumber:312
      },
      operationConfig:{
      dataSource:"PoApproval",
      operationType:"add"
      },
      componentId:"isc_DynamicForm_14",
      appID:"builtinApplication",
      operation:"PoApproval_add",
      oldValues:{
      },
      criteria:{
      }
      }
      === 2011-02-05 13:21:37,080 [l0-4] INFO IpIDACall - Performing 1 operation(s)
      === 2011-02-05 13:21:37,080 [l0-4] DEBUG AppBase - [builtinApplication.PoApproval_add] No userTypes defined, allowing anyone access to all operations for this application
      === 2011-02-05 13:21:37,080 [l0-4] DEBUG AppBase - [builtinApplication.PoApproval_add] No public zero-argument method named '_PoApproval_add' found, performing generic datasource operation
      Initializing AS/400 connection for environment IPTSFILI
      Initializing AS/400 program call to IP664P
      CHGJOB INQMSGRPY(*DFT)
      Executing AS/400 program call: IP664P
      === 2011-02-05 13:21:37,220 [l0-6] INFO RequestContext - URL: '/ipgui/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)': Moz (Gecko) with Accept-Encoding header
      === 2011-02-05 13:21:37,220 [l0-6] INFO Download - File C:/Eclipse-Workspace/IPGui/war/ipgui/sc/system/reference/skin/images/server_client_exchange.png not found, sending 404
      [WARN] 404 - GET /ipgui/sc/system/reference/skin/images/server_client_exchange.png (127.0.0.1) 1450 bytes
      Request headers
      Host: 127.0.0.1:8888
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)
      Accept: image/png,image/*;q=0.8,*/*;q=0.5
      Accept-Language: en
      Accept-Encoding: gzip,deflate
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 115
      Connection: keep-alive
      Cookie: ipgui_skin_name=Enterprise; PoItemCanvasGroupLevel=item; ipgui_last_environment_name=iptsfili; JSESSIONID=xb8mytrfea2k; GLog=%7B%0D%20%20%20%20left%3A1%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A640%2C%20%0D%20%20%20%20height%3A480%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D
      Referer: http://127.0.0.1:8888/ipgui/sc/system/helpers/Log.html
      Response headers
      Content-Type: text/html; charset=iso-8859-1
      Content-Length: 1450
      === 2011-02-05 13:21:37,455 [l0-6] INFO RequestContext - URL: '/ipgui/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)': Moz (Gecko) with Accept-Encoding header
      === 2011-02-05 13:21:37,455 [l0-6] INFO Download - File C:/Eclipse-Workspace/IPGui/war/ipgui/sc/system/reference/skin/images/server_client_exchange.png not found, sending 404
      [WARN] 404 - GET /ipgui/sc/system/reference/skin/images/server_client_exchange.png (127.0.0.1) 1450 bytes
      Request headers
      Host: 127.0.0.1:8888
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)
      Accept: image/png,image/*;q=0.8,*/*;q=0.5
      Accept-Language: en
      Accept-Encoding: gzip,deflate
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 115
      Connection: keep-alive
      Referer: http://127.0.0.1:8888/ipgui/sc/system/helpers/Log.html
      Cookie: ipgui_skin_name=Enterprise; PoItemCanvasGroupLevel=item; ipgui_last_environment_name=iptsfili; JSESSIONID=xb8mytrfea2k; GLog=%7B%0D%20%20%20%20left%3A1%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A640%2C%20%0D%20%20%20%20height%3A480%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D
      Response headers
      Content-Length: 1450
      Content-Type: text/html; charset=iso-8859-1
      === 2011-02-05 13:21:43,814 [l0-4] INFO DSResponse - [builtinApplication.PoApproval_add] DSResponse: Map with 1 keys
      === 2011-02-05 13:21:43,814 [l0-4] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2011-02-05 13:21:43,830 [l0-4] DEBUG RPCManager - non-DMI response, dropExtraFields: false
      === 2011-02-05 13:21:43,986 [l0-4] INFO Download - Returning 304: Not modified on conditional get of: C:\Eclipse-Workspace\IPGui\war\ipgui\sc\skins\Enterprise\images\ListGrid\sort_descending.png
      === 2011-02-05 13:21:44,220 [l0-4] INFO Download - Returning 304: Not modified on conditional get of: C:\Eclipse-Workspace\IPGui\war\ipgui\sc\skins\Enterprise\images\ListGrid\sort_ascending.png
      === 2011-02-05 13:21:44,220 [l0-4] INFO Download - Returning 304: Not modified on conditional get of: C:\Eclipse-Workspace\IPGui\war\ipgui\sc\skins\Enterprise\images\ListGrid\header_Selected.png
      === 2011-02-05 13:21:44,330 [l0-4] INFO RequestContext - URL: '/ipgui/sc/skins/Enterprise/images/Splitbar/hsplit_snap.png', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)': Moz (Gecko) with Accept-Encoding header
      === 2011-02-05 13:21:44,330 [l0-4] INFO Download - done streaming: C:/Eclipse-Workspace/IPGui/war/ipgui/sc/skins/Enterprise/images/Splitbar/hsplit_snap.png
      === 2011-02-05 13:21:44,330 [l0-4] INFO RequestContext - URL: '/ipgui/sc/skins/Enterprise/images/Splitbar/hsplit_bg.png', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)': Moz (Gecko) with Accept-Encoding header
      === 2011-02-05 13:21:44,330 [l0-4] INFO Download - done streaming: C:/Eclipse-Workspace/IPGui/war/ipgui/sc/skins/Enterprise/images/Splitbar/hsplit_bg.png
      === 2011-02-05 13:21:44,408 [l0-4] INFO RequestContext - URL: '/ipgui/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)': Moz (Gecko) with Accept-Encoding header
      === 2011-02-05 13:21:44,408 [l0-4] INFO Download - File C:/Eclipse-Workspace/IPGui/war/ipgui/sc/system/reference/skin/images/server_client_exchange.png not found, sending 404
      [WARN] 404 - GET /ipgui/sc/system/reference/skin/images/server_client_exchange.png (127.0.0.1) 1450 bytes
      Request headers
      Host: 127.0.0.1:8888
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)
      Accept: image/png,image/*;q=0.8,*/*;q=0.5
      Accept-Language: en
      Accept-Encoding: gzip,deflate
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 115
      Connection: keep-alive
      Referer: http://127.0.0.1:8888/ipgui/sc/system/helpers/Log.html
      Cookie: ipgui_skin_name=Enterprise; PoItemCanvasGroupLevel=item; ipgui_last_environment_name=iptsfili; JSESSIONID=xb8mytrfea2k; GLog=%7B%0D%20%20%20%20left%3A1%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A640%2C%20%0D%20%20%20%20height%3A480%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D
      Response headers
      Content-Type: text/html; charset=iso-8859-1
      Content-Length: 1450
      === 2011-02-05 13:21:56,158 [l0-4] INFO RequestContext - URL: '/ipgui/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)': Moz (Gecko) with Accept-Encoding header
      === 2011-02-05 13:21:56,158 [l0-4] INFO Download - File C:/Eclipse-Workspace/IPGui/war/ipgui/sc/system/reference/skin/images/server_client_exchange.png not found, sending 404
      [WARN] 404 - GET /ipgui/sc/system/reference/skin/images/server_client_exchange.png (127.0.0.1) 1450 bytes
      Request headers
      Host: 127.0.0.1:8888
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E)
      Accept: image/png,image/*;q=0.8,*/*;q=0.5
      Accept-Language: en
      Accept-Encoding: gzip,deflate
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 115
      Connection: keep-alive
      Referer: http://127.0.0.1:8888/ipgui/sc/system/helpers/Log.html
      Cookie: ipgui_skin_name=Enterprise; PoItemCanvasGroupLevel=item; ipgui_last_environment_name=iptsfili; JSESSIONID=xb8mytrfea2k; GLog=%7B%0D%20%20%20%20left%3A-4%2C%20%0D%20%20%20%20top%3A-4%2C%20%0D%20%20%20%20width%3A1280%2C%20%0D%20%20%20%20height%3A699%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D
      Response headers
      Content-Length: 1450
      Content-Type: text/html; charset=iso-8859-1

      Comment


        #4
        What are you saying the problem is? Your RPC requests and responses show that the validation error prevented the save. You mention an "Add request which is done with the save" - this did not encounter a validation error, so it went through (as expected).

        Also, the server logs are clearly incomplete.

        Comment


          #5
          when line 1 executes it returns true when the error on the console and RPC say that it is false. Should it not return false. If I don't use DMI and use a Range validation which would run on the client it works properly.

          Another validate is done on save (line 2) which the RPC says is false but the saveData adds the record. I believed that because the second validation failed that it would not save and populate the ErrorMessage which I would be able to read with .getError() on the reponse.

          1-> if (getForm().validate(true)) {
          DSRequest requestProperties = new DSRequest();
          String[] poNumbers = getPoNumbers();
          String prompt = null;
          if (poNumbers.length == 1) {
          prompt = "Approving blockout " + poNumbers[0];
          }
          else {
          prompt = "Approving selected blockouts";
          }
          requestProperties.setPrompt(prompt);

          2-> getForm().saveData(new DSCallback() {
          @Override
          public void execute(DSResponse response, Object rawData, DSRequest request) {
          Record responseData = response.getData()[0];
          Record[] statusList = responseData.getAttributeAsRecordArray(PO_APPROVAL_FIELD_poStatusList);
          PoApprovalReviewDialog myReviewDialog = new PoApprovalReviewDialog(new IpOkCancelCallback() {
          @Override
          public void onOk() {
          doOk();
          }
          @Override
          public void onCancel() {
          doCancel();
          }
          });
          myReviewDialog.setPoApprovalStatusList(statusList);
          myReviewDialog.enable();
          myReviewDialog.centerInPage();
          myReviewDialog.show();
          myReviewDialog.bringToFront();
          }
          }, requestProperties);
          }

          Comment


            #6
            DMI validators execute asynchronously since there's a server trip. The true value for validate() is just telling you that client-side validators passed, and an attempt to save to the server will happen if you call saveData().

            Comment


              #7
              How on the client side do a Test for this server-side validation and retrieve the error message if their is one. I need to be able to prevent the save from happening. Is their a callback I can use.

              Comment


                #8
                saveData has a callback, and it normally fires only if there's no error, which is what you want. Note you can pass willHandleError:true via the DSRequest argument to indicate that you want to be called back even if there is an error.

                Comment


                  #9
                  Ok.

                  1) If server-side validations do not prevent saves(do not generate errors on the server-side response when update,add are executed), and its results are not part of validate() then what is it's ended use.

                  2) Should I code the validation call on the server-side when an add or update is done and put the error in the response.

                  Thanks in advance

                  Comment


                    #10
                    Validation prevent saves as your own logs show. That is their purpose. There is no need to add any more validation code than you have or than is shown in the sample.

                    The only thing you are doing wrong is doing a related save without checking whether the primary save was rejected due to your validation rules, and we just explained how to do that.

                    Comment

                    Working...
                    X