Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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

Avoiding validation when hitting the Cancel button

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a DispatchAction and TestForm (extends ValidatorForm). I want to
avoid validation when the user clicks the Cancel button. Currently the
Cancel button is coded like this

<html:submit value="Cancel" property="command">

public class TestAction extends DispatchAction {

public ActionForward Cancel(ActionMapping mapping, ActionForm form, HttpRequest..) {
return mapping.findForward("mainpage");
}
}


When I click cancel, the Cancel method is not called.. because the Validation of the form takes place before hands and the form gets back to the view.
 
author & internet detective
Posts: 41851
904
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dan,
There is an html:cancel tag for this purpose. It bypasses the validation.
 
Dan Waters
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok if I use

<html:cancel>. How do I identify the Cancel action in my Action class, because
I need to forward to a different screen when a Cancel button is pressed.
 
Jeanne Boyarsky
author & internet detective
Posts: 41851
904
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dan,
Just have your action call:
isCancelled(request)
 
reply
    Bookmark Topic Watch Topic
  • New Topic