Class CmsValidationScheduler


  • public class CmsValidationScheduler
    extends java.lang.Object
    This is a helper class for scheduling form validations.

    Since validations can be asynchronous, it would be possible for a validation to start while another one is still waiting for a response from the server if it were ran directly. This might result in an inconsistent state of the form fields being validated. To prevent this, validation controllers use this class to schedule validations, and call this class again after they're finished to execute the next validation.

    The result of this is that a validation will only start after all unfinished validations which have been scheduled before it have finished running.

    Since:
    8.0.0
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CmsValidationScheduler()
      Hidden default constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void executeNext()
      This method should be called by the validation controller when it has finished running.
      static CmsValidationScheduler get()
      Returns the singleton instance of the validation scheduler.
      void schedule​(CmsValidationController action)
      This schedules a new validation to be run after all currently scheduled or running validations have finished.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • get

        public static CmsValidationScheduler get()
        Returns the singleton instance of the validation scheduler.

        Returns:
        the validation scheduler
      • executeNext

        public void executeNext()
        This method should be called by the validation controller when it has finished running.

        It will execute the next validation if there is one.

      • schedule

        public void schedule​(CmsValidationController action)
        This schedules a new validation to be run after all currently scheduled or running validations have finished.

        If there are no validations running, the validation will be started immediately.

        Parameters:
        action - the validation to be scheduled