This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Spring and the fly likes Which controller I have to use for a page having multiple submit buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Which controller I have to use for a page having multiple submit buttons" Watch "Which controller I have to use for a page having multiple submit buttons" New topic
Author

Which controller I have to use for a page having multiple submit buttons

Raaja Gotluru
Ranch Hand

Joined: Mar 02, 2010
Posts: 108
Hi,

I am new to Spring MVC and I am having a page with three buttons for this which controller I have to use. Is this be possible with all the three buttons as submit buttons or I have to use one as submit button and the other two as normal buttons and using onclick should I have to submit this form for these two buttons.

Please guide me.

Thanking you
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Either would work but it sounds like you question is can you use multiple submit buttons for a single spring form. The answer is yes (Assuming your using Spring 3).





If you use this method note that if the form is submited via pressing the enter button (rather than clicking the button) some browsers dont send a param. In this case it is important to define a 'default action' which should be the first submit defined on the form.

Alternatively you could use this approach as well and handle both submit buttons with the same request handler:



[How To Ask Questions][Read before you PM me]
Raaja Gotluru
Ranch Hand

Joined: Mar 02, 2010
Posts: 108
Hi Mr. Bill,

Thank you for the reply. Yes my question is the same what you understand. Actually I am in to struts 1.3 and working with that for more than 3 years. Just I got an opportunity to work in Spring. In struts we have Mapping Dispatch Action and LookupDispatch Action. I am trying to know is there any classes like these two in Spring also.


I will try it according to your reply and let you know if there is any problem.

--regards,
raaja g

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Which controller I have to use for a page having multiple submit buttons
 
Similar Threads
checkbox
servlets+screept
Which controller I have to use for a page having multiple submit buttons
2 submit buttons with different action
Using two forms in net beans 6 + spring +tomcat