• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Avoiding validation when hitting the Cancel button

 
Dan Waters
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33716
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan,
There is an html:cancel tag for this purpose. It bypasses the validation.
 
Dan Waters
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 33716
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan,
Just have your action call:
isCancelled(request)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic