wood burning stoves 2.0*
The moose likes Struts and the fly likes By pass Struts Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "By pass Struts Validation" Watch "By pass Struts Validation" New topic
Author

By pass Struts Validation

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 117
I am doing struts validation server side. How do I by pass validation during runtime, because I have 2 buttons on the same form. One is accept and another is save. When I click save it should by pass validation during run time.

Thank you,
Luke.
Paul Lester
Ranch Hand

Joined: Dec 27, 2002
Posts: 40
There is nothing in struts that requires that you do validation. When you click the submit button, the framework will call the ActionForm.validate method. You need not override that method at all and no validations will be done. The method will still be called on the parent class, ActionForm, but it will never return any errors.


Where Photography meets vision.<br /><a href="http://www.photogravision.com" target="_blank" rel="nofollow">http://www.photogravision.com</a><br />Please stop by!<br /> <br />SCJP,SCWCD,SCJD,SCEA
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 117
Hello All,

Just now found the answer of how to by pass validation in struts. To allow the user to cancel the submit and bypass the validations, a flag can be set. If the Submit button sets bCancel to true, then the Struts Validator will pass control through to the Action.

Thanks,
Luke.

PS: The "click" was mis-spelled debilrately. But in real coding do spell it in the proper way.
Aaron Ting
Ranch Hand

Joined: Dec 13, 2005
Posts: 78
Actually, regarding this requirement you are talking about, if i am not wrong, the developer can actually set whether the method needs to be validated via the struts-config.xml..

For example, i have this method, "/add".. so the coding goes,

Hope this information helps..


[ December 19, 2005: Message edited by: Aaron Ting ]

If you can't convince them, confuse them!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: By pass Struts Validation
 
Similar Threads
How to ByPass the validation framework
Dynamic validation for struts2
DynaValidatorActionForm not working
Struts Validation - DatePattern MM/dd/yy
XML Parsing error