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

Form.MULTIPART_HINT is not cleared correctly with nested forms

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.9
    • 1.4.11, 1.5-M2.1
    • wicket
    • None

    Description

      I have a page that looks like this

      • Page
        • Form
          • Wizard (contains another Form)
            • StepOne - contains a FileUploadField
            • StepTwo - has no FileUploadField

      (The outer form is there because I have some controls outside the wizard that needed to submit the wizard too).

      Because I have been using Ajax ModalDialogs, it has been important to get Form.multipart set correctly (otherwise they don't submit back correctly). So I override Wizard.onActiveStepChanged and checked to see if the new wizard step contained a FileUploadField, and set Form.setMultiPart accordingly. However, this only clears Form.MULTIPART_HARD, Form.MULTIPART_HINT is left untouched.

      When I step from StepOne to StepTwo, the inner form still has MULTIPART_HINT set as it contained a FileUploadField last render. Then the outer form's onRender fires, which clears MULTIPART_HINT, then the outer form's onComponentTag fires. When it checks isMultiPart(), it evaluates to true as the nested Form still returns true from its MULTIPART_HINT, and therefore tag.put("enctype", "multipart/form-data"); is executed. After that, the inner form's onRender fires which clears its MULTIPART_HINT.

      When I try to submit StepTwo, the html has enctype="multipart/form-data", so it does a multipart submit. But wicket is not expecting a multipart submit so it doesn't find any of the submitted form data, and cannot determine which button is pressed, and loses all the form content.

      Attachments

        1. wicket-2933.tar.gz
          13 kB
          Martin Grigorov
        2. WICKET-2933-quickstart.zip
          48 kB
          Alex Grant
        3. WICKET-2933-with-Exception.zip
          23 kB
          Alex Grant
        4. WICKET-2933-with-Exception.zip
          45 kB
          Alex Grant

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            ivaynberg Igor Vaynberg
            alexgrant Alex Grant
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment