| Author |
Avoiding validation when hitting the Cancel button
|
Dan Waters
Greenhorn
Joined: May 07, 2004
Posts: 11
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26201
|
|
Dan, There is an html:cancel tag for this purpose. It bypasses the validation.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Dan Waters
Greenhorn
Joined: May 07, 2004
Posts: 11
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26201
|
|
Dan, Just have your action call: isCancelled(request)
|
 |
 |
|
|
subject: Avoiding validation when hitting the Cancel button
|
|
|