Announcement Announcement Module
Collapse
No announcement yet.
2 buttons with 2 destinations in a simpleFormController? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2 buttons with 2 destinations in a simpleFormController?

    Hi!

    I have a form with 2 input fields and 2 buttons - a submit button and a back button.

    when the user press the submit butten the validator checks if the form is correctly filled out - if yes - the controller (simpleFormController) will be called and so on...
    but I have a 2nd button - the back button - if the user presses this button he should be redirected back to the page he was before.

    at first I tried to realize this by using javascript's history:back() function. but this doesn't work well in this case. because if the user doesn't correctly fill out the form it will be displayed again where the user will be informed about the invalid input... and if the user put in twice or more times invalid input - the form will be displayed again and again with the warnings.

    so when I use the javascript's history.back() function - the user will be redirected just 1 step back (where the form and the warning were displayed yet)

    my question: how can I realize the form - so that the submit button forwards to another location than the back button? can a simpleFormController handle 2 forms or should I use another controller (which?) or???
    any ideas?

    tia.lana

  • #2
    If you use AbstractFormController, you can override processFormSubmission to return whatever ModelAndView you need, i.e. to go back or wherever.

    I'd stay away from the browser back button.

    When returning a ModelAndView from processFormSubmission, you can, for example, return.

    new ModelAndView("my.tiles.name", someMapModel);

    new ModelAndView("redirect:somePage.htm", someMapModel);

    as some possible variations.

    Comment

    Working...
    X