cancel
Showing results for 
Search instead for 
Did you mean: 

InitDefaultInterceptor not capturing values entered during creation

Former Member
0 Kudos

Hi,all I implemented an InitDefaultsInterceptor for a Product as follows:

public class DefaultInterceptor implements InitDefaultsInterceptor { public void onInitDefaults(final Object obj,final InterceptorContext arg1) {

                               if(obj instanceof ProductModel)
                              {
                                        final ProductModel productModel = (ProductModel) obj;
                                        System.out.println(productModel.getCode());
                           }
               }

} I registered this interceptor as follows in the file myextension-spring.xml:

Former Member
0 Kudos

The formatting of your questions is broken, therefore we can't read everything. Please fix it and explain what you're trying to achieve. How should the default value be calculated?

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member469962
Contributor
0 Kudos

Hello Rachit,

There are different types of interceptors meant for different stages in model's lifecycle. :https://wiki.hybris.com/display/release5/Interceptors#Interceptors-LifeCycleofaModel.

As Andrew explains: Init Defaults Interceptor is triggered when the model is populated with defaults values. You may look at this table to decide which type of Interceptor suits your requirement.

Hope this helps.

Br, Shwetha

andyfletcher
Active Contributor
0 Kudos

The InitDefaultsInterceptor fires when the model is created. This is before it saves any data to it. The model will always be empty at this point. It's meant for you to set default values.