• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts Cancel Button submits the form

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic