File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Cancel Button submits the form" Watch "Struts Cancel Button submits the form" New topic

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:


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.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Struts Cancel Button submits the form
Similar Threads
struts-config.xml file errors
Cannot find bean coursesList in any scope
Struts validation framework- for single form, multiple actions
<global-forwards> problem in struts-config.xml
Deploying struts1.29 appl to struts 1.3.10