• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

By pass Struts Validation

 
Luke Zechariah
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Luke Zechariah
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic