Hi, I have 2 buttons on one jsp, one is submit button and the other is back. I want to use only one action form to handle both the events, I am using DynaValidatorForm. So the problem i amfacing is, the fields get validated even if i press the back button, Is there a way to make sure that the validation occurs only when i press submit button
Hi Ashish, You can define two action mappings in the struts-config.xml file which uses one action form. So for the first tag you say validate=true and for another tag you say validate=false. If you specify validate=false then the validate method in action form does not execute. For example For submit button ----------------- <action path="/submit" type="someclass" name="DynaValidateForm" validate="true" input="/xxx"> </action> For back button --------------- <action path="/back" type="someclass" name="DynaValidateForm" validate="false" input="/xxx"> </action>
---<br />Time flies like an arrow,<br />Fruit flies like a banana
Joined: Sep 15, 2000
Hi Jessi, I think you dint got the problem completely. Pl have a look at the bold letters in the question and let met know your opinion. I want to use only one action form to handle both the events. I am using DynaValidatorForm here he is talking about one action form handling two different actions and not two submit buttons handling one single action. And also the problem is with handling validations in the actionform i hope so. Loke . --------------- I am never afraid of tommorow, since i saw yesterday and i love today.
Joined: May 30, 2002
Sorry guys, Ignore my ramblings above. I guess it's good practice to read the post one is replying to, huh Jesse
Originally posted by ashish kulkarni: Hi, I have 2 buttons on one jsp, one is submit button and the other is back. I want to use only one action form to handle both the events, I am using DynaValidatorForm. So the problem i amfacing is, the fields get validated even if i press the back button, Is there a way to make sure that the validation occurs only when i press submit button
Since you are saying you are using one jsp, I will assume both buttons are on the same form and therefore submitting to the same action. Set validation to false in your struts config file. In the action that is called, determine which button was pressed to submit the form. Depending on which button was pressed, manually call the form's validate method or use a validator class if appropriate. [ December 31, 2002: Message edited by: Jason Menard ]
Rather than start a new topic, I decided to just dig this one back up since it is essentially the same problem I'm having.
I have two buttons that are supposed to submit to the same Action. One button is an actual "Submit" button that I want to require validation from my ActionForm. The other is a "Logout" button that should not be validated.
I have tried setting validation="false" in my struts-config for this action forward and then called the ActionForm's validate method directly from the Action class' submit method.
This partially works. It results in the Logout not requiring validation and logging out correctly.
Submit does validation and submits if validation passes and returns to the original JSP if validation fails.
The problem though is when returned to the original JSP I'm not able to display the ActionErrors because it is empty! How can I get this to stay populated using the method I have described?