Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1995

Method called unnecessarily in FormComponent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.4-RC1
    • 1.4-RC2
    • wicket
    • None
    • all

    Description

      In class FormComponent, in method validate(), isValid() is called too many times.

      The last call can be removed by refactoring as follows:

      Original 1.4 code:

      public void validate()
      {
      validateRequired();
      if (isValid())
      {
      convertInput();

      if (isValid() && isRequired() && getConvertedInput() == null && isInputNullable())

      { reportRequiredError(); }

      if (isValid())

      { validateValidators(); }

      }
      }

      Refactored:

      public void validate()
      {
      validateRequired();
      if (isValid())
      {
      convertInput();

      if(isValid())
      {
      // Check again because we think that convertInput() can set
      // input to null after validateRequired() found valid input.
      // When can convertInput() set input to null again?
      if (isRequired() && getConvertedInput() == null && isInputNullable())

      { reportRequiredError(); }

      else

      { validateValidators(); }

      }
      }
      }

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            bht@actrix.gen.nz bernard
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: