aspose file tools*
The moose likes Struts and the fly likes Struts Cancel Button submits the form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Cancel Button submits the form" Watch "Struts Cancel Button submits the form" New topic
Author

Struts Cancel Button submits the form

Aalok Mishra
Ranch Hand

Joined: Dec 23, 2008
Posts: 41
Hi All,

i am using the struts tag lib in my code. I have created an image control to use instead of traditional buttons. The submit button works fine but the cancel button is not behaving proprly. It just submits the form instead of cancelling it when the cancel button is pressed. Can any one help me in this?

Here is my code:
Login.jsp


Struts-config.xml


Thanks and Regards,
Aalok Mishra
InfoCepts, LLC
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you'll look closely at The Taglib documentation, you will see that an html:cancel button does cause a submit button to be rendered. The main difference is that it will bypass any validation. If your action class is a subclass of DispatchAction as yours appears to be, just code a cancelled method to handle the case where the cancel button is pressed. Also, don't forget to put cancellable="true" in the action path definition in your struts-config.xml file.


Merrill
Consultant, Sima Solutions
 
 
subject: Struts Cancel Button submits the form