| Author |
Multipage form validation
|
Alok Pota
Ranch Hand
Joined: Mar 07, 2001
Posts: 185
|
|
validation.xml ============== <form-validation> <formset> <form name="/EditWorkOrder"> <field property="dealerName" depends="required" page="1"> <arg0 key="Dealer name" resource="false" /> </field> <field property="customField1" depends="required" page="2"> <arg0 key="Customer field 1" resource="false" /> </field> </form> </formset> </form-validation> The form is session scope. and my two JSP pages have the following. page1.jsp ========= <html:form action="/EditWorkOrder" > <html:hidden property="page" value="1" /> ... </html:form> page2.jsp ======== <html:form action="/EditWorkOrder" > <html:hidden property="page" value="2" /> ... </html:form> struts-form.xml (merged into the struts-config) ================================================ <form-bean name="EditWorkOrderForm" type="org.apache.struts.validator.DynaValidatorActionForm"> <form-property name="dealerName" type="java.lang.String" /> <form-property name="customField1" type="java.lang.String" /> </form-bean> I still don't get any validation. I can jump from one page to another. Am I missing something?
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
Originally posted by Alok Pota: <form-validation> <formset> <form name="/EditWorkOrder"> <field property="dealerName" depends="required" page="1"> <arg0 key="Dealer name" resource="false" /> </field> <field property="customField1" depends="required" page="2"> <arg0 key="Customer field 1" resource="false" /> </field> </form> </formset> </form-validation>
You need to refer to forms using their name (i.e. "EditWorkOrderForm"), not using the name of the Action the form submits to.
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Dan Waters
Greenhorn
Joined: May 07, 2004
Posts: 11
|
|
No, he has defined his form to be a DynaValidatorActionForm and so the validation is tied to the action and not the form. He would have to tie the rules to the form if it was defined as DynaValidatorForm ..
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
Originally posted by Dan Waters: No, he has defined his form to be a DynaValidatorActionForm and so the validation is tied to the action and not the form. He would have to tie the rules to the form if it was defined as DynaValidatorForm ..
Hmm. That was new to me. Thanks.
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
This is very good ttutorial about Validate Framework of Struts. http://www.javaranch.com/newsletter/Mar2003/newslettermar2003.jsp#struts
|
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
|
 |
 |
|
|
subject: Multipage form validation
|
|
|