Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3826

Dialog validation is ignored when a ValidatingSaveHandler is attached to the dialog definition

    XMLWordPrintable

Details

    Description

      We've added a custom ValidatingSaveHandler to the Page Info dialog for our pages.
      Adding this has caused the original mandatory fields on the dialog, which were working beforehand, to become optional (despite still being marked with a *).

      After some debugging, we've isolated the fault as follows:

      The validate() method in DialogMVCHandler contains the following:

      boolean passed = this.getDialog().validate();
      
      SaveHandler saveHandler = this.getSaveHandler();
      if (saveHandler instanceof ValidatingSaveHandler) {
           passed = ((ValidatingSaveHandler) saveHandler).validate();
      }
      

      As you can see, this ignores the results of dialog validation if a ValidatingSaveHandler is present.

      We suggest changing this to:

      boolean passed = this.getDialog().validate();
      
      SaveHandler saveHandler = this.getSaveHandler();
      if (saveHandler instanceof ValidatingSaveHandler) {
           passed = passed && ((ValidatingSaveHandler) saveHandler).validate();
      }
      
      

      We've worked around the problem at the momentby explicitly calling this.getDialog().validate() from our ValidatingSaveHandler, but this isn't really satisfactory.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              mdivilek Milan Divilek
              rgibson Rory Gibson
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD