This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I have got a form ,which I need to validate using validation.xml.To reach this form I use a link forward from the main page.This form has some values which get filled from the database so the action needs to be executed atleast once.But when if the action gets executed (using link action) for getting data from the database the validation happens and results in display of all errors when the page is first displayed.
Good advice from Nick. If you think about it the term "action" implies that something is happening...a verb. My general naming convention is to have a verb as part of my action name. I don't have an "Employee" action. Instead I have a "DisplayEmployee" action and a "SaveEmployee" action.
In Struts-Config.xml file i made the validation="false". then then validation is not happening. I am using the Dispatch action. If validation="True" means while page loading itself validation happens.
Can you explain the solution clearly. I di't understand.
Joined: Jan 06, 2007
when you put validation="true" every time you hit that action it will validate the backing form configured. So if you have a dispatch action with methods like setup, add, edit, delete, or what have you, you're still hitting that action. When you hit the action struts looks at the config to which action you're going to. It'll say oh this action is MyDispatchAction, then it sees that validation is set to true and tries to validate it, no matter what method it's going to dispatch to.
When using dispatch action I normally just call the form validation from the methods that need to be validated.
the struts validation flag is set to the action, not each individual method.
You could get tricky and override the dispatch method look for the name of the method and validate it if it falls within the methods you want to validate, if you do that, look at the source code to dispatch action and see what it's doing and you'll get the idea.