Announcement

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

    ListGrid validation error message not displayed

    Hi

    When a validation error occurs from my (GWT) server, I do the following:

    final Map<String, String> fieldErrors = new HashMap<String, String>();
    fieldErrors.put("name", "This should be my error message");
    final DSResponse response = new DSResponse();
    response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
    response.setStatus(DSResponse.STATUS_VALIDATION_ERROR);
    response.setErrors(fieldErrors);

    This works with a DynamicForm but when using a ListGrid the error message shown against the column (named 'name') is always "undefined" !!! Why? If I explicitely use ListGrid.setFieldError(row, "name", "This should be my error message") the ListGrid displays the right message!

    Can you help. Many thanks

    #2
    Possibly a bug in the GWTRPCDataSource, try posting in that thread.

    Or just use SmartGWT Pro, where this and many other things are handled automatically..

    Comment


      #3
      This is not a bug in the datasource.

      The following code does not work with a ListGrid:
      Code:
      final Map<String, String> fieldErrors = new HashMap<String, String>();
      fieldErrors.put("name", "This should be my error message");
      final DSResponse response = new DSResponse();
      response.setErrors(fieldErrors);
      response.setStatus(DSResponse.STATUS_VALIDATION_ERROR);
      processResponse(request.getRequestId(), response);
      This is probably a bug in the class ListGrid, because it works in a DynamicForm

      See ListGrid.parseServerErrors() function.
      Code:
      for (var fieldName in errors) {
      var fieldErrors = errors[fieldName];
      if (isc.isAn.Array(fieldErrors)) {
      for (var i = 0; i < fieldErrors.length; i++) {
      fieldErrors[i] = fieldErrors[i].errorMessage;
      }
      } else {
      errors[fieldName] = [fieldErrors.errorMessage];
      }
      }
      This function expects a errorMessage property which you can 't set with the method
      Code:
      DSResponse.setErrors(Map errors)
      Workaround:
      Code:
      final Record record = new Record();
      record.setAttribute("errorMessage", "Name is invalid");
      JavaScriptObject valueJS = JSOHelper.createObject();
      JSOHelper.setAttribute(valueJS, "name", error.getJsObj());
      final DSResponse response = new DSResponse();
      response.setErrors(valueJS);
      response.setStatus(DSResponse.STATUS_VALIDATION_ERROR);
      processResponse(request.getRequestId(), response);

      Comment


        #4
        Hi avthart,
        I have opened similar thread quite a while ago:
        http://forums.smartclient.com/showthread.php?t=6211
        and got false opinion that the problem is with WSDataSource.

        Thanks very much for your workaround - great !

        I hope that Isomorphic will take care of this bug finally.
        MichalG

        Comment


          #5
          Created an issue, see:
          http://code.google.com/p/smartgwt/issues/detail?id=361

          Comment

          Working...
          X