PDA

View Full Version : skip validation on click of cancel button


Rojiwadiya Dinesh
Oct 12th, 2007, 03:30 AM
Hi all,
I had a simple from which contains two submit buttons (cancel,save).

if any of the buttons are pressed it goes into myvalidation class,I want to
skip validation on click of cancel button.
Is there any way i can check the request is from cancel button and skip in myvalidation class.

Any suggestions are welcome:)

Thanks,
Dinesh

Lori
Oct 12th, 2007, 03:56 AM
I would suggest using this form controller:
http://www.springframework.org/docs/api/org/springframework/web/servlet/mvc/CancellableFormController.html

Marten Deinum
Oct 12th, 2007, 05:16 AM
Or override the suppressValidation (http://www.springframework.org/docs/api/org/springframework/web/servlet/mvc/BaseCommandController.html#suppressValidation(java x.servlet.http.HttpServletRequest,%20java.lang.Obj ect,%20org.springframework.validation.BindExceptio n)) method in the SimpleFormController. Check which button is clicked (cancel or save) and return true of false.


return WebUtils.hasSubmitParameter(request, "cancel");