Announcement Announcement Module
No announcement yet.
Validator Framework Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validator Framework

    I had a situation before where i wanted to use Spring's Validator interface around my business services. The scenario was i wanted to automatically call the validate method when a service method is invoked.
    i am not using Spring MVC, which allows validation at binding level. Anyway, i had to do a workaround & using AOP i tried to proxy each business service & inject the validator on certain method patterns, as shown
    <bean id="aliasValidatorDao" class="validation.core.factory.ValidatorProxyFactoryBean">
                <property name="target">
                    <bean class="">
                            <property name="oracleProcedureSupport"> <ref bean="oracleProcSupport" /></property>   
                <property name="methodPatterns"><value>insert*,update*</value></property>
                <property name="validator">
                    <bean class="" />
                 <!--setting this to false will disable the validation -->
                <property name="validate"><value>true</value></property> 
                <property name="messageTypeHolder"><value></value></property>
    The ValidatorProxyFactoryBean actually is responsible for creating the actual proxy. Developer creates the validator i.e. AliasValidator & only is concerned with validations related to the current scenario.
    Furthermore, StrutsMessagesSupport implements the Errors interface & uses internally ActionMessages.
    Anyway, i hope this approach was worth the effort. If you do like what you see or if you think there is a better way of configuring this [maybe through AspectJ], please let me know. Most of us don't have luxury of using Spring MVC, moreover i rather have all validations done on the service side [complex ones]
    Last edited by Spring Guy; Jun 6th, 2006, 09:52 AM.