Bradley M. Handy wrote:
I ran into this problem last week. I fixed this by creating an initial action mapping (ie. showform) to show the form and not validate anything. Then make sure all submit buttons submit to your action mapping that does validate. Not too hard. I've included a sample configuration to illustrate.
... <action-mappings> <!-- - default action. Show the form and does nothing else. - Notice the lack of a "parameter" attribute. --> <action path="/index" type="example.Action" unknown="true" name="paymentForm" validate="false" scope="session"> <!-- forwards and exceptions --> </action>
<!-- - default action. Show the form and does nothing else. - Notice the "parameter" attribute. --> <action path="/payment" parameter="action" type="example.Action" name="paymentForm" validate="true" input="form.payment" scope="session"> <!-- forwards and exceptions --> </action> </action-mappings> ...
I could have used DispatchAction or LookupDispatchAction, but last time I checked they didn't support a "default" action if the "parameter" was null or empty. (I could be wrong.)
-----Original Message-----
From: David Chelimsky [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 8:59 PM
To: Struts Users Mailing List
Subject: [struts-user] How to NOT validate a form???
I'm using Struts 1.1rc1. I've got validation on a StoryForm that includes a required field (headline). My StoryAction extends DispatchAction and contains several methods, one of which is called "init". If story_id is in the query string, this method will populate the form with data from the identified story. If not, it just renders an empty form. The problem is that the validator seems to be engaged prior to this method ever being called and I'm seeing my "HEADLINE is required" message.
How do I render an empty form in this scenario? I want to render it empty and validate it on submit only.
Thanks for reading.
David ============= <!-- struts-config.xml --> <form-beans> <form-bean type="StoryForm" name="storyForm" /> </form-beans>
<action-mappings> <action path="/story_editor/work" type="StoryAction" name="storyForm" parameter="method" scope="request" input="work.jsp" > <forward name="edit_story" path="work.jsp"/> </action> </action-mappings>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]