Results 1 to 6 of 6

Thread: Cancel or submit a page without binding ?

  1. #1
    Join Date
    Oct 2004
    Posts
    6

    Default 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. #2
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    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,
    Darren Davison.
    Public Key: 0xE855B3EA

  3. #3
    Join Date
    Oct 2004
    Posts
    6

    Default

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

  4. #4
    Join Date
    Aug 2004
    Location
    Paris
    Posts
    43

    Default

    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.

  5. #5
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    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,
    Darren Davison.
    Public Key: 0xE855B3EA

  6. #6
    Join Date
    Aug 2004
    Location
    Paris
    Posts
    43

    Default

    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.

Similar Threads

  1. Replies: 9
    Last Post: Apr 24th, 2007, 06:59 AM
  2. Replies: 17
    Last Post: Jan 2nd, 2007, 01:43 PM
  3. Pageable data list with Hibernate
    By robmorgan in forum Data
    Replies: 23
    Last Post: Jul 24th, 2006, 06:12 PM
  4. Replies: 3
    Last Post: Aug 26th, 2005, 01:36 AM
  5. Replies: 2
    Last Post: Aug 17th, 2004, 04:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •