Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-86

Add support for "cancel" submit buttons (which bypass client-side validation)

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.15
    • Fix Version/s: 5.2.0
    • Component/s: None
    • Labels:
      None

      Description

      There is a need for more submit types...
      although <input type="submit"> and <input type="reset"> are trivial even without a component,
      there is a problem when a type="cancel" is needed.

      The issue here is that in case of cancel client validation must be skipped, and that is not possible with current
      Submit component.

      I don't know how submit type=cancel works for T4 so I've implemented it how it seemed right for me.

      extract from javadoc for the "type" parameter

      • Determines the button behavior, <b>"submit"</b> - a normal form button, <b>"reset"</b> - reset form (locally),
      • "cancel" - works like an actionlink, generates a "cancel" event instead of "selected" and the form is not submitted
      • (if javascript is disabled form will be submitted, and "cancel" event fired as well),
      • <b>"submitcancel"</b> - works like "cancel" but behaves consistently with and without javascript
      • submission (this is usually desirable).

      input type=cancel uses javascript to redirect to an action link url, thus avoiding form submission,
      so I've added type=submitcancel which still submits the form but avoids client validation.

      both generate "cancel" event which is different from the "selected" event

      on top of all that the type=forced could be easily added to call "selected" event while skipping client side validation

      1. TAPESTRY-2109.patch
        6 kB
        Davor Hrg
      2. TAPESTRY-2109-R629196.patch
        6 kB
        Davor Hrg

        Issue Links

          Activity

          Hide
          hlship Howard M. Lewis Ship added a comment -

          Along the way, I added a cancel parameter to BeanEditForm to include a "Cancel" button, and a "canceled" event (for when the BEF's cancel button is clicked).

          Show
          hlship Howard M. Lewis Ship added a comment - Along the way, I added a cancel parameter to BeanEditForm to include a "Cancel" button, and a "canceled" event (for when the BEF's cancel button is clicked).
          Hide
          hlship Howard M. Lewis Ship added a comment -

          I think we can have the Form submit normally, bypassing validation, and recognize that on the server. Thus, no action link, etc.

          I think we can make this work with the LinkSubmit component as well.

          Show
          hlship Howard M. Lewis Ship added a comment - I think we can have the Form submit normally, bypassing validation, and recognize that on the server. Thus, no action link, etc. I think we can make this work with the LinkSubmit component as well.
          Hide
          9902468 Ville Virtanen added a comment -

          The ability to submit the form WITHOUT validation is really important. For an example I have a list of tu -objects and user can add as many as he/she likes. I have all kinds of other data in the form, and the add tu button must send all that other data to server while at the same time so that no data is lost during the tu addition. Hence actionlink cannot be used.

          And this must not initiate client side nor server side validation, user can add as many tu:s as she/he likes before entering any other data. That other data is not needed until save operation that happens when user SAVES the form.

          • 99
          Show
          9902468 Ville Virtanen added a comment - The ability to submit the form WITHOUT validation is really important. For an example I have a list of tu -objects and user can add as many as he/she likes. I have all kinds of other data in the form, and the add tu button must send all that other data to server while at the same time so that no data is lost during the tu addition. Hence actionlink cannot be used. And this must not initiate client side nor server side validation, user can add as many tu:s as she/he likes before entering any other data. That other data is not needed until save operation that happens when user SAVES the form. 99
          Hide
          cherrydev Cherry Development added a comment -

          Also, please add in a type="image" !
          I had hoped I could simply subclass Submit and override beginRender, but the Submit class is final.

          Show
          cherrydev Cherry Development added a comment - Also, please add in a type="image" ! I had hoped I could simply subclass Submit and override beginRender, but the Submit class is final.
          Hide
          hrgdavor Davor Hrg added a comment -

          correct file that patches against R629196

          Show
          hrgdavor Davor Hrg added a comment - correct file that patches against R629196
          Hide
          hrgdavor Davor Hrg added a comment -

          Is this not a trivial fix ?
          The patch is already there ... why push it to 5.1 ?

          Show
          hrgdavor Davor Hrg added a comment - Is this not a trivial fix ? The patch is already there ... why push it to 5.1 ?
          Hide
          hrgdavor Davor Hrg added a comment -

          some api changes were made...
          here's the patch for Rev 612601

          Show
          hrgdavor Davor Hrg added a comment - some api changes were made... here's the patch for Rev 612601
          Hide
          mlusetti Massimo Lusetti added a comment -

          You may have look at http://code.google.com/p/tapestry5-components/ Button component.
          It's available only from trunk, will be in the next release.

          Show
          mlusetti Massimo Lusetti added a comment - You may have look at http://code.google.com/p/tapestry5-components/ Button component. It's available only from trunk, will be in the next release.
          Hide
          hlship Howard M. Lewis Ship added a comment -

          A cancel button can be accomplished as just an ActionLink. You can use CSS to dress it up like a form submit button if you like.

          Show
          hlship Howard M. Lewis Ship added a comment - A cancel button can be accomplished as just an ActionLink. You can use CSS to dress it up like a form submit button if you like.
          Hide
          hrgdavor Davor Hrg added a comment -

          ... also..
          unlike "selected" event the "cancel" event supports return value..
          this way you can use it to redirect to another page....

          Show
          hrgdavor Davor Hrg added a comment - ... also.. unlike "selected" event the "cancel" event supports return value.. this way you can use it to redirect to another page....
          Hide
          hrgdavor Davor Hrg added a comment -

          patch with test

          Show
          hrgdavor Davor Hrg added a comment - patch with test

            People

            • Assignee:
              hlship Howard M. Lewis Ship
              Reporter:
              hrgdavor Davor Hrg
            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development