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

Form#visitFormComponents can cause ClassCastException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 6.3.0
    • 6.5.0
    • wicket

    Description

      The current method signature of Form#visitComponents allows for passing in an implementation of IVisitor that will cause a ClassCastException.
      Example
      Add a CheckBox and TextField to the Form. Pass in an IVisitor<CheckBox> to visitComponents. There will be a ClassCastException when the IVisitor<CheckBox> attempts to visit the TextField.

      The method signature should be changed to
      public final <R> R visitFormComponents(final IVisitor<FormComponent<?>, R> visitor)
      or the method should be removed to prevent confusion.

      Attachments

        1. WicketQuickStart.zip
          32 kB
          Jesse Bonzo
        2. visitFormComponentsfix.patch
          0.9 kB
          Jesse Bonzo
        3. detectVisitorComponentClass.patch
          2 kB
          Andrea Del Bene

        Activity

          People

            Unassigned Unassigned
            vitiate Jesse Bonzo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: