Tapestry
  1. Tapestry
  2. TAPESTRY-2453

Form enctype is not updated when an Upload component is injected via FormInjector / AjaxFormLoop

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.13
    • Fix Version/s: 5.0.15
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      The following snipped describes the situation:

      <t:form>

      <ul>
      <li t:id="loop" t:type="AjaxFormLoop" source="uploads" value="currentValue" encoder="encoder">
      <t:submitnotifier>
      <t:upload value="currentValue.uploadedFile" />
      <t:removerowlink>remove</t:removerowlink>
      </t:submitnotifier>
      <t:parameter name="addRow">
      <t:addrowlink>Add a row</t:addrowlink>
      </t:parameter>
      </li>
      </ul>
      <t:submit>Submit</t:submit>

      </t:form>

      Adding a row to this form causes an addition of a Upload component. However when doing so the enctype of the form tag should be updated to "multipart/form-data". However this does not happen. I suppose that reverting the enctype back to normal when the last upload component is removed doesn't happen too.

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        The workaround is to ensure that the Form is always using the multipart encoding type (even if it does not contain a file upload). This could be accomplished with a simple mixin to the form. Dynamically managing the enctype on the client-side is possible in theory, but would be a bit on the unwieldy side.

        Show
        Howard M. Lewis Ship added a comment - The workaround is to ensure that the Form is always using the multipart encoding type (even if it does not contain a file upload). This could be accomplished with a simple mixin to the form. Dynamically managing the enctype on the client-side is possible in theory, but would be a bit on the unwieldy side.
        Hide
        Ognen Ivanovski added a comment -

        I agree, fiddling with the enctype on the client-side does sound shaky.

        But, since the elements inside the AjaxFormLoop are the same all the time, perhaps fixing the enctype to multipart can be done automatically by the loop (if it can peek down inside and "see" that there is an upload component within)?

        Show
        Ognen Ivanovski added a comment - I agree, fiddling with the enctype on the client-side does sound shaky. But, since the elements inside the AjaxFormLoop are the same all the time, perhaps fixing the enctype to multipart can be done automatically by the loop (if it can peek down inside and "see" that there is an upload component within)?
        Hide
        Howard M. Lewis Ship added a comment -

        Added some manual testing, as its not (to my knowledge) possible to test the upload element using Selenium.

        Show
        Howard M. Lewis Ship added a comment - Added some manual testing, as its not (to my knowledge) possible to test the upload element using Selenium.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Ognen Ivanovski
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development