Good afternoon helpers,
 
I've started a new application using struts 1.1 and I'm having some problems with some 
new concepts.
 
I want to use XML form validation (DynaValidatorForm) using validator-rules.xml and my 
validaton.xml. Right now my application is working fine. Now I want to use different 
validation rules for the same form, accross multiple JSPs. For example:
 
- TestForm is a DynaValidatorForm
  String name
  String address
 
- test1.jsp
  I want to show one text box to fill the "name" property:
 
(...)
  <html:text property="name" />
(...)
 
- test2.jsp
  I want to show one text box to fill the "address" property:
 
(...)
  <html:text property="address" />
(...)
 
- struts-config.xml
(...)
<form-beans>
    <form-bean name="testForm" type="org.apache.struts.validator.DynaValidatorForm">
      <form-property name="name" type="java.lang.String"/>
      <form-property name="address" type="java.lang.String"/>
    </form-bean>
</form-beans>
(...)
 
- validaton.xml
(...)
    <formset>
        <form name="logonForm">
            <field property="username" depends="required">
                <arg0   key="prompt.username"/>
            </field>
            <field property="address" depends="required">
                <arg0   key="prompt.address"/>
            </field>
        </form>
</formset>
(...)
 
Now, I run http://localhost/app/test1.jsp and I fill in my "name" property. Then I 
want my app to validate only the "name" property. Then I forward to test2.jsp, fill 
the "address" property and now I want to validate only the "address" property. How can 
I do this? The problem is, what identifies a rule in validation.xml is the form name. 
I could define different names for my form in the struts-config.xml but imagine if I 
had 10 JSPs for each form.
 
Thanks in advance
 
Rúben Carvalho
 
 
 
 
 

Reply via email to