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

Form#visitFormComponents can cause ClassCastException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 6.3.0
    • Fix Version/s: 6.5.0
    • Component/s: wicket
    • Labels:

      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. detectVisitorComponentClass.patch
          2 kB
          Andrea Del Bene
        2. visitFormComponentsfix.patch
          0.9 kB
          Jesse Bonzo
        3. WicketQuickStart.zip
          32 kB
          Jesse Bonzo

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: