Announcement

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

    sending error message using DSResponse

    Hi,

    We are using SmartGWT Pro 3.0 version.
    How we can display the error message sent from server, I did not found any API to get the error message set on server, below is my code example.

    On server side:-
    dsResponse.setFailure();
    List<String> errors = new ArrayList<String>();
    errors.add("some error message");
    dsResponse.setErrors(errors);

    On client side:-
    listGrid.addEditFailedHandler(new EditFailedHandler()
    {
    @Override
    public void onEditFailed(EditFailedEvent event)
    {
    // some business logic
    // how to display the error message received from server
    SC.say();
    }
    });

    #2
    The error message will already be displayed on the field. Are you trying to also display it in a pop-up?

    Be sure to read the Error Handling overview in the "docs" package in JavaDoc.

    Comment


      #3
      Yes I want to display customized popup on browser but there is no API available in DSResponse object to fetch the error set on server-side.

      How I am sending the response from server
      RPCManager rpc = new RPCManager(httpRequest, httpResponse);
      // some business logic
      DSResponse dsResponse = new DSResponse();
      dsResponse.setFailure();
      List<String> errors = new ArrayList<String>();
      errors.add("some error message");
      dsResponse.setErrors(errors);
      rpc.send(dsRequest, dsResponse);

      Comment


        #4
        You can use dsResponse.getErrors() to get at dsResponse errors on the client side when a save attempt has completed.
        If you're using the editFailed handler, you can use editFailedEvent.getDsResponse() to get at this object (a null check is a good idea here in case the edit failed directly on the client without ever being sent to the server).
        Alternatively as part of the save request you can set willHandleErrors to true on the dsRequest object, and then use a custom callback to look at the errors on the response object.

        Comment


          #5
          While sending error message from server DSResponse accept a list of erros and on client side dsResponse.getErrors() returns a map. What is the key to fetch the errors set on server.

          Comment


            #6
            dsResponse.getErrors() returns a Map from fieldName to the error message(s) for that field. This is the structure that is created by calls to the server-side API dsResponse.addError().

            There is no documented server-side API that allows you to provide a List of errors. Do not call undocumented methods - they are not supported and may be changed or removed at any time.

            Comment

            Working...
            X