Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2997

Changing form to utilise an enctype multipart/form-data disables the 'method' or 'action' attribute of a s:submit button

    XMLWordPrintableJSON

Details

    Description

      A simple form with multiple submit buttons, each going to a different action mapping (or method) works fine, for example:

      <s:form action="UpdateDocument" method="post">
      <s:submit title="Unpublish" method="unpublish" />
      <s:submit title="Publish" method="publish" />
      </s:form>

      The Unpublish button will invoke the unpublish method of the Action class mapped to the UpdateDocument action.
      Respectively, the Publish button will invoke the publish method of the Action class mapped to the UpdateDocument action.

      Attempt to change the form to use a multipart/form-data enctype (Which is important as we will be adding a file upload to this form), i.e.:

      <s:form action="UpdateDocument" method="post" enctype="multipart/form-data">
      <s:submit title="Unpublish" method="unpublish" />
      <s:submit title="Publish" method="publish" />
      </s:form>

      Each button press will now only invoke the prepate method within 'UpdateDocument', not the correct unpublish or publish method declared within the submit tag.

      Attachments

        Activity

          People

            Unassigned Unassigned
            deanpullen Dean Pullen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: