Announcement Announcement Module
Collapse
No announcement yet.
Cancel or submit a page without binding ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cancel or submit a page without binding ?

    A simple question: the function of a 'Cancel' (or 'Previous')submit button on a form is simply to leave the page and go to another one without doing anything with the data in the form
    What happens is that binding occurs even though logically the data in the form is to be ignored completely.

    An example of this in our case where we have registered a Date custom editor.
    Suppose a user enters 'abc' in the Date field and then presses Cancel in order to leave the page without storing anything previously entered. Binding will occur before we can effectively process the Cancel button, but the binder will result in an error that is shown to the user. And that is not what a user expects when he presses Cancel !

    What is your experience with this ?

  • #2
    Assuming your form controller can be made aware of the cancel request via a normal POST, then you can override suppressValidation(request) to return true..
    Code:
    protected boolean suppressValidation(HttpServletRequest request) {
      return (request.getParameter("cancelMe") != null);
    }
    Regards,

    Comment


    • #3
      No, the problem is not the validation; it is the binding that bugs me ! I don't see a way to skip the binding.

      Comment


      • #4
        yes really anoying, what we did is having two forms, one for a real submit, and the other for a cancel submit, the second one beeing empty, or having just the hidden fields necessary for navigation purpose. Works fine, if you don't post the data, there is no binding.

        Comment


        • #5
          it would work if you put the cancel button in its own form with a GET action wouldn't it?
          Code:
          <form action="" method="POST">
            <!-- form elements here -->
            <input type="submit"/>
          </form>
          <form method="GET" action="/path/to/cancelpage.html">
            <input type="submit" value="Cancel"/>
          </form>
          Regards,

          Comment


          • #6
            you could also want to put it in the same form, the cancel button will be a href link, with a javascript to submit, the cancel form. It works both way.

            Comment

            Working...
            X