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

    Problem with listgrid boolean field and save errors

    I am trying out a listgrid with a boolean-column. I want to auto-save the row when the user clicks the field. This works fine, i get the server call when the user clicks in the listrgid, however i am trying to get a working solution in the case where something bad happens on the server.

    The problem is that if something goes wrong, my default RPC error handler shows an error, but the checkbox still has the "new" value. I would like the value to revert to the "before" value, since it didn't change on the server.

    Preferrably, that would just happen, but since it doesn't i have tried adding an "EditFailedHandler", through which i thought i could perhaps revert the value myself. However, my default handler also kicks in and there seems to not be any way to set the equivalent of "setWillHandleErrors" that you can do when you kick off a DSRequest manually.

    So is there any way to

    1. make failed saves revert the checkbox value to the "before" value automatically?
    2. If thats not possible, make the "editfailedhandler" be the only errorhandler for a grid, and skip the generic rpchandler?

    Thanks (smartgwt 5.0-p20160121)

    You haven't really given us enough information here..

    Default behavior, if there is a validation error reported by your server, would be to show the validation error on the field and fire the EditFailed event. In that event you could throw away the pending change if you want.

    It seems like the reason you have a problem is *either* that your server is reporting total failure rather than a validation error, in which case you should report just a validation error instead, *or* you've customized the default error handling logic so that even a validation error results in a Warn dialog, in which case get rid of that behavior change.


      Hey, thanks for responding!

      OK, i'll try to give you more information. In my server-side service (a Spring bean), i simulated an error by sending back a DSResponse with status -1 and data "banana". This is what i guess you mean by "total failure" right? Again, i'm just testing, but it might happen if database goes down or something.

      This results in:

      1. The errorhandler i've defined in RPCManager.setHandleErrorCallback gets called.
      2. The edithandler i've added via grid.addEditFailedHandler ALSO gets called.

      So my questions are:

      1. On "generic" errors, is there a way for me to prevent the generic rpchandler to be called, like i can with dsrequest.sethandleerrors?
      2. How do you mean "in the editfailed event you could throw away the pending change". I can only see get-methods on the event object. I would like the checkbox value to be reverted also in the case of "total failure"

      Thankful for pointers.


        Again, unless the database is actually down, you probably want to signal a validation error rather than a total failure (which is what -1 means). The default handling for a validation error is to allow the component to deal with it. If you've changed this, un-change it.

        When the EditFailed event occurs, throw away the pending change with clearEditValue / discardEdits. These are standard ListGrid APIs, no need to restrict yourself to just the APIs on the event.

        Finally, if the problem is that the database is down, then you should think about what you want to do - it doesn't seem to be a particularly good idea to throw away the user's edits in this scenario. Most applications would halt further interactivity until the server is behaving normally again.



          normally i do as you suggest, this is a specific scenario with a listgrid that has one column which is editable, with a checkbox. When the user clicks it, it is sent to the server immediately, and thus if it doesn't go well, the value hasn't changed on the server, i want it to reflect the current value client-side. A validation error will never happen, it's a checkbox that can always be clicked.

          Any ideas on how i prevent the "generic" rpcerror from being displayed in this case? optimally i'd like a listgrid.seterrorhandler or something... since i don't put together the dsrequest myself here and thus cannot set willHandleErrors.


            The error code you send back is up to you. How you handle it is up to your custom RPCManager error handler. There's nothing in the framework that is preventing you from doing what you want here, you seem to have all possibly needed APIs at your disposal, so we're not sure what remaining question you have, if any.


              Well, my question was if i in some way could define a custom errorhandler specific to the listgrid, so that all errors for that listgrid goes to that errorhandler, just as i can do when i make a dsrequest manually. (Im talking about DSRequest.willHandleErrors) - i.e. bypassing the global RPCHandler for the listgrid.