Announcement Announcement Module
Collapse
No announcement yet.
Request parameters How to Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Thank you

    Thank You,

    I try to build a AbstratctWizardFormController. It don't show any problem and the page is load correctly but when I push in any link the page reload and does not do anything more.

    Why?

    Comment


    • #17
      AbstractWizardFormController don't enter in my onSubmit method. Why?

      There are another method?

      Comment


      • #18
        In the final jsp that is displayed before the form is finished make sure you have

        <input type="hidden" name="_finish" value="true" />

        in your form.

        Comment


        • #19
          Must I have only one controller for all the jsp?

          Comment


          • #20
            Praedos, I don't remember if Sprang mentioned this, but you want the submit from the form page to go back to the same/original controller. There are 2 http requests; the original GET which displays the form, and then when the user clicks the submit button there's a POST, which should also go back to the same controller which handled the GET. You do not want the form's ACTION to specify a url that will send it to a different controller. This is because if there are any errors in the user's input the controller can redisplay the form page for them.

            Comment


            • #21
              Originally posted by praedos View Post
              Must I have only one controller for all the jsp?
              Get it to work with a single page form. Make it a two page web application; page 1 is the form where you enter the information, page 2 simply displays the information you entered in the form.

              In the above when I say "page" I mean url. In Spring MVC urls are mapped to controllers. So one way to do this is to have page 1, the form page, have its own controller, and page 2, the display page, will have its own controller. Since they are separate urls you'll need to do a redirect at the end of page 1 after the form is submitted and validated, redirecting to page 2.

              I think your question has to do with how you transfer the data that was entered into the form when you make the transition from page 1 to page 2.

              You could let spring transfer the data to the next page, but it could be a lot, and when you do the redirect spring will put the data in the url as GET parameters since that's the only way spring can transfer the data for you. That's what happens when you put the data in the ModelAndView and then specify a view like

              Code:
              "redirect:page2"
              You could instead store the data in a session variable. Or you could store it in a database, since you'll probably want it there eventually anyways, and just pass some sort of user id or transaction id between the pages in a session variable, or as a GET parameter. Then page 2 uses the userId to retrieve the data from the database, puts it in the model, and returns a ModelAndView that displays it.

              In the form submit method for page 1 you can put the userId in the ModelAndView and specify the view with a redirect: and spring will add the userId to the GET parameter(s).

              This may be more work than you'd like to do but I think it's a useful exercise.

              A shorter way to do it would be to have page 1's controller, the form page, return the view that's the one from my above example that was used by page 2 (page2.jsp for example).

              The other thing that I think can help clear up a lot of confusion is to not subclass any of the various spring form controllers, how it was done prior to spring 2.5, and use the annotation stuff instead. Then your controller is just a plain old class that's annotated with @Controller and you annotate its methods saying which respond to the GET request, the POST request, and the ones that provide the "reference data".

              Comment


              • #22
                It's run!

                Thank you a lot, lumpynose!

                And thank to all people that try to help me.

                Comment

                Working...
                X