Hi,
I have written a class that implements the Validator interface.The following is the code
Here firstName is the field name in the bean class.And i have included this validator in the servlet xml as follows :Code:public class ValidateRegistration implements Validator { public boolean supports(Class clazz) { return clazz.equals(RegistrationInfo.class); } public void validate(Object command,Errors errors) { RegistrationInfo registrationInfo = (RegistrationInfo) command; ValidationUtils.rejectIfEmpty(errors, "firstName", "required.firstName"); } }
But it is not validating.Is there something i should do in the jsp page?Code:class="com.dispatcher.RegistrationController"> <property name="formView" value="registration"></property> <property name="successView" value="RegSuccess"></property> <property name="registrationService" ref="registrationService" /> <property name="validator"> <ref bean="registrationValidator" /> </property> </bean> <bean id="registrationValidator" class="com.dispatcher.ValidateRegistration"></bean>
Can anyone let me know this.


Reply With Quote