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

Method called unnecessarily in FormComponent

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4-RC1
    • Fix Version/s: 1.4-RC2
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: