Search code examples
springspring-mvcbroadleaf-commerce

how to extend a component for custom logic?


In BLC, I want to provide custom logic to validate shipping and billing form. The two validators are defined as in below code and are being used in BroadleafShippingInfoController and BroadleafBillingInfoController respectively.

@Component("blShippingInfoFormValidator")
public class ShippingInfoFormValidator implements Validator

@Component("blBillingInfoFormValidator")
public class BillingInfoFormValidator implements Validator 

Is there any way by which I can create my custom validator classes which can be used in place of ShippingInfoFormValidator and BillingInfoFormValidator in BLC framework?


Solution

  • Found a way to do this, it is more of spring configuration than anything else.

    Suppose CustomShippingInfoFormValidator is an extension of ShippingInfoFormValidator then i just have to add following line to spring configuration file

    <bean id="blShippingInfoFormValidator" class="package.to.CustomShippingInfoFormValidator" />