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 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 Android Security Essentials Live Lessons this week in the Android 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Cancel Button submits the form
 
Similar Threads
Cannot find bean coursesList in any scope
Deploying struts1.29 appl to struts 1.3.10
<global-forwards> problem in struts-config.xml
Struts validation framework- for single form, multiple actions
struts-config.xml file errors