You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pavlikus <pa...@bk.ru> on 2004/06/22 15:05:41 UTC

Re[2]: I Wondor Why Validation Doesn't Validate

ML> Dear Friends

ML> Thank you very much for your attention; I checked both 'validate="true" '
ML> and also 'empty spaces', they didn't solve the problem.
ML> Actually the part of 'if (!errors.isEmpty())' returns false all the time(see
ML> below, section 4).
ML> My previous project is already working properly with 'validate="false"', but
ML> this one.... :( 

ML> Again any help would be appreciated

ML> Thank you
ML> Nafise

Hi. I not very familiar with DynaForms... But in case of regular
Action Forms any resources I've read  suggest to define all form
fields as a Strings.

But you do:
form-property name="studentId" type="java.lang.Integer" />

May be this help you.
Also, correct me please if I be mistaken.


ML> -----Original Message-----
ML> From: cn@mail.cn-consult.dk [mailto:cn@mail.cn-consult.dk] 
ML> Sent: Monday, June 21, 2004 5:51 PM
ML> To: Struts Users Mailing List
ML> Subject: Re: I Wondor Why Validation Doesn't Validate

ML> Nafise said:

>> I did the follow steps for setting validation, but there is no error on an
>> empty field checking 'chequeNumber' (see below plz).
>>
>>
>> 1. Placing the validation.xml & validator-rules.xml in WEB-INF folder
>> 2. In struts-config.xml :
>>    a.	<plug-in
>> className="org.apache.struts.validator.ValidatorPlugIn">
>> 		<set-property
>> 			property="pathnames"
>> 			value="/WEB-INF/struts/validator-rules.xml,
>> 				 /WEB-INF/struts/validation.xml" />
>> 	</plug-in>
>>
>>     b. <form-bean name="CreditStudentForm"
>> 	           type="org.apache.struts.validator.DynaValidatorForm">
>>
>>             <form-property name="chequeNumber" type="java.lang.String"/>
>> 		<form-property name="studentId" type="java.lang.Integer" />
>> 		<form-property name="dispatch" type="java.lang.String" />
>>
>>
>>   	 </form-bean>
>>
>>     c. <action path="/creditStudent" parameter="dispatch"
>> type="com.pdpsoft.lms.struts.action.CreditStudentAction"
>>                name="CreditStudentForm" validate="false" scope="session"/>

ML> I am aware that it is not what you want, but what happens if you set
ML> validate="true"?

>> 3. In validation.xml :
>>
>>       <form name=" CreditStudentForm ">
>>             <field
>>                 property=" chequeNumber "
>>                 depends="required">
>>             </field>
>> 	</form>

ML> Could the spaces in <form name> and <field property" be a problem ?

>> 4. In Action:
>>
>> 	ActionErrors errors = dynaForm.validate(mapping, request);
>>       if (!errors.isEmpty()) {    //this if is never true :(
>>             saveErrors(request, errors);
>>             return mapping.findForward("aForward");
>>         }
>> 5. In jsp:
>>
>> 	<html:errors/>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org