Form validation failing : how do you re-display data ?

Discussions

Web tier: servlets, JSP, Web frameworks: Form validation failing : how do you re-display data ?

  1. I would like to know how you generally handle this very simple use case with common MVC frameworks :
    - 1 : one page (call it A) displays a list of items, and a small form. (The controller "A" loads the list, initializes the form, and forwards the request to the "A.jsp" file)
    - 2 : the user submits the form with erroneous data (passing throught client-side validation) to a controller named "B".
    - 3 : the controller B detects the validation error, and *forwards* the request to A.jsp directly without .

    Now, how do you re-display the list of items previously displayed on page A ? Did you put it in session ? Do you call Controller A again ? Do you let Controller B load data to be displayed on page B ? Did you put all your viewbeans inside the FormBean and in session ? What if you have more than one form on a page ?

    My opinion is , following the RPG pattern, that Controller B should *redirect* the user to the initial page. Then, the data would be reloaded (come on, it's cached), and the user would be able to call a "Refresh", and later also to press the "back" button of his browser.

    What do you usually do ? what do you think ?
  2. If there is a lot of data outside of the form that I needed to get, I usually go back to controller A because I've already written the code in controller A to get the data and put it into the request. Maybe I'll throw in a special case for if the page is being reloaded, but thats about it.
  3. I usually go back to controller A

    Sounds good to me, but how do you perform this ?
    Do you usually invoke the execute() method ? forward the request ? send a redirect ?
    Don't you think that any MVC fwk should handle such kind of mechanism ?
    a special case for if the page is being reloaded

    Should a web application fall in a "special case" when the user presses his "refresh" button after posting a non-validated form ?
  4. I use Struts so for my pages I mark that I'm validating it for a specific page and give it the name of the page that was used for the input form. Struts takes care of managing the request data and if there was a validation error then struts goes to the marked input form. Otherwise it proceeds to the action that was defined by the form.