Announcement

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

    how to set a handler for validation errors

    Hi all,

    I have a ListGrid.
    I have a button which calls saveAllEdits() on the ListGrid.
    How do I install a callback for validation errors?
    The errors are displayed all right, but I would like to take further actions. (Like re-enable the save button which I have disabled when it was clicked, to avoid duplicate save attempts.)

    I tried to use addEditFailedHandler(), but it does not seem to be called. (Contrary to what the docs say.)

    Thank you for your help!

    #2
    You should see the editFailedCallback called in this case - can you modify an example to demonstrate that it is not?

    However, for your particular use case, it seems like you could unconditionally re-enable the save button when the callback to saveAllEdits() fires.

    Comment


      #3
      It is really strange, and I might be wrong, but it seems to me that when the validation fails on the client site, the callback does not fire.

      Here is the code:

      Code:
      saveButton = new IButton("save");
      saveButton.addClickHandler(new ClickHandler() {
      	@Override public void onClick(ClickEvent event) {
      		disable();
      		cancelButton.disable();
      		listGrid.saveAllEdits(new Function() {
      			@Override public void execute() {
      				Window.alert("e!");
      				saveButton.enable();
      				cancelButton.enable();
      			}
      		});
      	}
      });
      When I enter an invalid text (like letters instead of numbers),
      a validation error icon (and text) is displayed, but the Window.alert is not called, and the buttons are not re-enabled.

      Comment


        #4
        It's intended that it does not fire on failure, as the most common use case is just detecting that saving is complete and you can move on. For anything finer grained than a simple "all done" notification, you need to add handlers for editComplete and editFailed, so you get row-by-row data.

        For your particular situation, the default behavior is already to show a blocking prompt during the save, so you don't have to worry about disabling the button in the first place. If you've disabled this behavior, probably the simplest thing is to just turn it back on.

        Comment


          #5
          Originally posted by Isomorphic
          For your particular situation, the default behavior is already to show a blocking prompt during the save, so you don't have to worry about disabling the button in the first place. If you've disabled this behavior, probably the simplest thing is to just turn it back on.
          Where do I configure this "blocking prompt"? How do I configure it?
          I don't think I have disabled it, but have not seen it working either.

          Comment


            #6
            Via "showPrompt", which can be configured at the DataSource or DSRequest/RPCRequest level.

            Comment

            Working...
            X