Hi there,

am having a problem validating a form manually using the
DynaValidatorForm.validate() function. For some reason, when validation
is carried out this way it only seems to find errors in one of the form
fields - however, if I set the validate="true" property in the
struts-module-config.xml file, validation does seem to be carried out
properly, which suggests to me that I did not make a mistake in the
validation configuration. Since I want to use DispatchAction however, I
can't use validate="true", as I need to validate the form selectively
for one of the methods only. 

I have tried using ValidatorLookupdispatchForm, but can't use it as
Struts 1.1 (which I am using) seems to have a bug with the set-property
tag in the module-config.xml file. Also tried latest version of Struts
(1.1, was using 1.1rc3) and of the validator (1.0, 1.02, latest nightly
build). My code is as follows - pretty straightforward:

<Action>
                DynaValidatorForm thisForm = (DynaValidatorForm)form;
                ActionErrors errors=thisForm.validate(mapping,request);
                
                Integer var1= (Integer)thisForm.get("var1");
                (... get more form vars...)
                
                //if errors, back to form
                if (!errors.isEmpty()) {
                        saveErrors(request, errors);

                        return mapping.getInputForward();
                 }
</Action>

<struts-module-config.xml>
        <action input="/editUserDetails.vm" name="details_form"
                        path="/details" 
                        scope="request"
                        parameter="method"
                        type="com.inc.modules.users.DetailsAction"
                        validate="false">
                <!-- not working in struts 1.1
                <set-property property="validateMethod(doEdit)" value="true"/>
                <set-property property="validateMethod(viewEdit)" value="false"/>
                <set-property property="validateMethod(viewDetails)" value="false"/> 
                -->
                   <forward name="view" path="/viewUserDetails.vm" redirect="false"/>
        </action>
</struts-module-config.xml>

<validation-module.xml>
        <form name="details_form">
                <field
                                property="var1"
                                depends="required,integer">
                                        <msg name="required" key="errors.required"/>
                                        <arg0 name="required" key="forms.var1"/>
                                        <msg name="integer" key="errors.integer"/>
                                        <arg0 name="integer" key="forms.var1"/>
                </field>
        </form>
</validation-module.xml>

I have spent almost 2 days trying to figure ways of getting around this
- anyone have any ideas?

Thanks,
Elie


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to